Is there a variable in Rails that equates to the template that is being rendered?
- by Sean Ahrens
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
...