Reputation: 19356
I want to render the same view in the controller for all my actions. For instance, I have:
class FooController
def action1
#action1 code
end
# [...]
def actionN
#actionN code
end
end
And then I want that all actions render generic_page.html
.
I tried with:
...
after_filter :render_generic
...
private
def render_generic
render 'generic_page'
end
But render
method is being called before after_filter
and I'm getting a Template Missing
error because it isn't rendering the correct template. Does anyone know a simple solution for that problem?
Upvotes: 2
Views: 1997
Reputation: 1609
using rescue_from
class FooController
rescue_from ActionView::MissingTemplate do
render 'generic_page'
end
end
Upvotes: 6
Reputation: 18784
I would just be explicit:
def action1
#action1 code
render_generic
end
def actionN
#actionN code
render_generic
end
private
def render_generic
render 'generic_page'
end
Upvotes: 2