Reputation: 2777
I am using Rails 4 for first time. Documentation says you can pass an instance variable to a partial:
<%= render partial: "customer", object: @new_customer %>
So I try to do the same. I am using fullcalendar engine and I render index.html.erb and inside that I render form partial. I pass @record to partial. I know the record is not nil because I added inspect_record helper to inspect that the @record does exist:
<%= render "form", :object => @record %>
<%= inspect_record @record %>
However, in _form.html.erb partial, the @record is nil, and this condition returns false:
<% unless @record.nil? %>
Note I also tried this:
<%= render 'form', locals: {record: @record} %>
What might I be doing wrong?
Upvotes: 0
Views: 559
Reputation: 9747
If you are using:
<%= render 'form', locals: {record: @record} %>
then, you will need to use variable record
instead of @record
in your _form.html.erb
as:
<% unless record.nil? %>
Description:
locals: {record: @record}
means, @record
's value will be accessible by using record
in the partial being rendered.
Upvotes: 1