Reputation: 18318
In the code snippet below, it appears that the form_user_fields partial does not have access to either patient_form or user_fields, but it does have access to @patient. Is this the expected behavior?
<%= form_for @patient do |patient_form| %>
<%= patient_form.fields_for :user do |user_fields| %>
<% render :partial => 'shared/form_user_fields' %>
Upvotes: 1
Views: 465
Reputation: 124419
In general, partials have access to the same variables as other views(instance variables from the controller.) They won't have access to variables that you create in other views that include the partials, that is the expected behavior.
If you want access to your local variables, you can pass them to the partial:
<%= render :partial => "shared/form_user_field", :locals => {:user_fields => user_fields, :patient_form => patient_form} %>
Upvotes: 4