Modularized controller can't find application_helper methods

Hey everyone,

Im having this weird problem. I made a controller by calling it
home/my_inbox to try to modularize everything. However, I cant call any
methods from the application_helper.rb file. Any reason why?

NoMethodError in Home/my inboxController#message

undefined method `book_viewing_message?’ for
#Home::MyInboxController:0x3a311b0

RAILS_ROOT: ./script/…/config/…
Application Trace | Framework Trace | Full Trace

#{RAILS_ROOT}/app/controllers/home/my_inbox_controller.rb:12:in
`message’

Aryk G. wrote:

home/my_inbox to try to modularize everything. However, I cant call any

It looks like you are trying to call it directly from the controller,
you should be calling the method from the view template instead. Methods
defined in application_helper.rb are available to all view templates,
not directly from the controller.

(You can do it, but you need to define a couple of other things inside
the Application Controller, and it’s not very clean)

I’d personally put the required methods into a separate class/module in
the lib directory and then require them from the controllers you need to
use.

Mac

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs