undefined local variable or method `f' for #<#:0x000001080edfe0>
I am trying to render a form within a template page with:
<%= form_for @vehicle, html: { class: "f_grp" }, remote: true do |f| %>
<%= render "vehicles", locals: { f: f } %>
<% end %>
The file is loading. But I'm getting an undefined method on f
error. Any ideas?
You only use :locals
when you use :partial
.
Either of these are correct:
<%= render partial: 'vehicles', locals: { f: f } %>
Or (as of Rails 2.3):
<%= render 'vehicles', f: f %>
Your version, which combines both, creates a local called locals
and sets its value to a hash containing f: FormBuilder...
.
It's worth noting that the only reason to still use locals:
is when you use render :collection
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With