Is there any way to pass a variable through to an instance in a show partial? Basically I'm creating a service that follows CRUD and want to be able to iterate an instanced variable. I can create it by passing a partial like so:
In the parent view:
<%= form_for(@report) do |f| %>
<%= render :partial => "reports/forms/partial_form", :locals => {:g => f, :var => "01"} %>
<% end %>
In the partial view:
<label><%= "Enter Data for Variable #{lane_number}" %></label>
<%= g.text_field :"Variable_#{var}" %>
This is useful the variables in the partial have a similar-enough naming convention to use the same var
to iterate through several items. This works just fine.
I would like to do something similar when viewing the input data, but I can't figure out how to pass that var
to the instance variable.
In the parent view:
<%= render :partial => "reports/shows/partial_show", :locals => {:var => "01"} %>
In the partial view:
<%= @report.Variable_#{var} %>
I know that #{var}
is just used for string interpolation (which is why it works in the original create), but is there a way for me to do this by passing the variable to the partial?