Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 main 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.

like image 817
Mathuvathanan Avatar asked Dec 12 '25 00:12

Mathuvathanan


1 Answers

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
like image 73
miguelsan Avatar answered Dec 16 '25 03:12

miguelsan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!