我有这样的代码.
class User < ActiveRecord::Base end module Foo class User end end module Foo class DoesSomethingWithActiveRecordUser def initialize user_id User.find(user_id) end end end
如果我调用Foo :: DoesSomethingWithActiveRecordUser.new(1)我收到一条错误消息,上面写着Foo :: User的未定义方法’find’.
谢谢.
解决方法
像这样:
::User.find(user_id)