putting helpers in application_controller.rb

I came across this mailboxer example http://josephndungu.com/tutorials/private-inbox-system-in-rails-with-mailboxer halfway down the page where the author puts some helpers in application_controller.rb ( helper_method :mailbox, :conversation) Why does he put them there? Why not create them as files under app/helpers ?

I came across this mailboxer example http://josephndungu.com/tutorials/private-inbox-system-in-rails-with-mailboxer halfway down the page where the author puts some helpers in application_controller.rb ( helper_method :mailbox, :conversation) Why does he put them there? Why not create them as files under app/helpers ?

You'd have to ask the developer to be sure, but my guess is that they don't want you to have to repeat yourself -- the helpers are coming from the gem, and the helper_method method just registers them with the application so they can be found. You would do the same thing if you had written a helper and wanted it to be available everywhere. I have seen Rails apps with the line: helper_method :all in the application_controller.rb, but admittedly, that was a long time ago, and I think that became the default. Thinking through this as I write, my suspicion is that whatever replaced helper_method :all did so with a read through the helpers folder, finding all the helper modules and requiring them into the Application Controller. But that's just a guess. So as a gem author, the developer is probably trying to find a good balance between getting the code they've written into your application through "magic" or deliberate action on your part (so you can get a sense for how things are hooked into your app).

Walter

Thanks Walter