How to get the current view name from layout template in Rails? -


Is it possible to get the name of footage presently present in the layout?

I did something similar to the CSS name space:

  # Config / initializers / action_view.rb ActionView :: TemplateRenderer .class_eval do def render_template_with_tracking (template, layout_name = zero, local = {}) # With this gsub, we get a file path / folder1 / folder2 / sffolder / filename.arb To subfolder-filename @ view.instance_variable_set (: @ _rendered_template, template.inspect.gsub (/(\..*)/,) .split ('/') [- 2 ..- 1] .join Do ('-')) Out = Reader_Template_with_tracking (template, layout_ Village, locals) @ view.instance_variable_set (: @_ rendered_template, zero) last alias_method_chain: render_template back tracking end # application.html.erb & lt; Body class = "& lt;% =: @_render_template% & gt; & Gt;  


Comments

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

c# - NameSpace Manager or XsltContent to parse aspx page -