How to access Rails 3 engine models in rails console
In the mail app's rails console (irb), how to access engine's models.
update: Say "team" is my main app and "team_page" is the engine. "team_page" is required in ma开发者_JAVA技巧in app in the gemfile through 'gem => "team_page", :path => "local/path/to/team_page"'. when I go to team's rails console, I couldn't access team_page's models.
First you must know the module's name. To help with that, you can run a
bundle show team_page
to find its directory and explore over there (probably under lib/team_page.rb
) until
you see the following definition:
module TeamPage
# ...
end
Let's say that the module is called TeamPage
. Then just prepend double colon to its name like this:
::TeamPage::SomeModel.some_method
精彩评论