Reputation: 21551
My application_helper.rb
is getting pretty big. In my defense, it contains only HTML-generating methods, and none of those methods perform any sort of business logic. None of the methods are specific to any page or controller, and most are unrelated to each other.
What's the typical solution to this problem? Suck it up? Create additional *_helper.rb
files to absorb some of application_helper
's methods?
Upvotes: 3
Views: 195
Reputation: 12837
Typically I organise by type - e.g. button_and_link_helpers, conditional_helpers etc. I just create them as modules and include them in the controllers that need them. This has the benefit of not loading loads of unused functions for every view
Upvotes: 3
Reputation: 40333
Usually we have helpers for controllers (one helper per controller, were you would place helper methods used only on that controller's templates) and you can also create helpers based on your own organization.
If you have many methods related to polls, you could create a PollsHelper and place all methods in there, even if there isn't a controller called PollsController. Also, Rails always loads all helpers and includes them in your views, so you can name them whatever you like (as long as they're inside the helpers folder and they end with _helper).
Upvotes: 5