I am using the Rails 5 ApplicationController.renderer.render method to render inside the model. I need to pass some variables to my layout, which I did with the locals option; this variable is then available in the layout if it can be obtained directly, but not through self .
This is how I set up the rendering
html_string = ApplicationController.renderer.render( file: "/#{template_path}/base/show", :formats => [:pdf,:html], locals: { :@routing_form => self, :controller_name => controller_name, :action_name => action_name, :current_user => current_user }, :layout => '/layouts/application' )
Then in the layout I want to do something like this.
<div id="foo" class="<%= self.action_name %>">
I managed to get this working by dropping self on this particular instance
<div id="foo" class="<%= action_name %>">
but now I'm worried about how to set a variable so that it works correctly with self ? I used to use the render_anywhere gem, and this was handled using rendering_controller.var = "value"
source share