Is there a variable in Rails that equates to the template that is being rendered?
Posted
by Sean Ahrens
on Stack Overflow
See other posts from Stack Overflow
or by Sean Ahrens
Published on 2010-06-03T05:30:46Z
Indexed on
2010/06/03
5:34 UTC
Read the original article
Hit count: 224
ruby-on-rails
I can do request.path_parameters['controller'] and request.path_parameters['action'], but is there anything like request.path_parameters['template'] so I can discern which template file (such as index.html.erb) is being rendered?
I'm writing a method that automatically sets the body id to the template being rendered, for easy css manipulation:
class ApplicationController < ActionController::Base
...
after_filter :define_body_selector
...
def define_body_selector
# sets @body_id to the name of the template that will be rendered
# ie. if users/index.html.erb was just rendered, @body_id gets set to "index"
@body_id = ???
end
...
© Stack Overflow or respective owner