Use an object from outside your modules scope

ruby, ruby-on-rails-3

Solution

Like this:

::User.find(user_id)

Problem

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.

Original source

Related problems