Reputation: 994
I'm trying to define a form_for with a local variable, like section 3.4.4
I can get it to work using an instance variable, but not with a local one.
This works:
Controller.rb
@new_instance = @instance_creation.get_instance #gives a proper object
view:
= render :partial => '/shared/instances_new'
partial view:
<%= form_for (@new_instance) do |f| %>
This does not:
Controller.rb
@new_instance = @instance_creation.get_instance #gives a proper object
view:
= render :partial => '/shared/instances_new',
:new_instance => @new_instance
partial view:
<%= form_for (new_instance) do |f| %>
error:
undefined local variable or method `new_instance' for #<#<Class:0x007f8e27dd7b30>:0x007f8e27b0f100>
What I am doing wrong?
Upvotes: 1
Views: 1597
Reputation: 578
Try passing object as local
= render :partial => '/shared/instances_new', :locals=>{:new_instance => @new_instance}
Upvotes: 1