Reputation: 24550
I need to call a method defined in a helper which uses content_for
, I need to render some buttons& links at lots of views.
The question is, how can I benefit from the before_filter ? I know its not designed for helpers, so, what's the proper way to do so ?
Currently, I am calling the helper method at most of views, which seems not practical.
Upvotes: 1
Views: 1512
Reputation: 50057
A before_filter
will not be of any help here. A before_filter
is used inside the controller, to execute method before starting an action. Generally, what one does:
In your case, what I would consider are:
application.html.erb
to group the shared views togetherapplication.html.erb
Hope this helps.
Upvotes: 3
Reputation: 27637
If you're calling a method in a bunch of views, you probably want to put it in the application layout (by default app/views/layouts/application.html.erb
)
Upvotes: 1