I have code like this.
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
If I call Foo::DoesSomethingWithActiveRecordUser.new(1)
I get an error message that says something like undefined method 'find' for Foo::User
.
How do I call the ActiveRecord User from within Foo
?
Thanks.
Like this:
::User.find(user_id)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With