Reputation: 415
I have an edit page that uses a semantic_form_for tag
<%= semantic_form_for @photog do |f| %>
The form is getting quite long and I would like to break it up into sections so that the view is more readable.
I am trying to create partials within the edit.html.erb template such as
<%= render 'favorite_things', locals: {f: f} %>
This code breaks saying undefined local variable or method `f' for #<#:0x007ff5a110abf0>
I need to understand how to pass the f object so that the partial can read it and things like f.input work
<!-- favorite things partial -->
<div class='edit_photog_header'>A List Of Your Favorites</div>
<%= f.input :fav_lens, :label => "Lens" %>
<%= f.input :fav_camera, :label => "Camera" %>
[and so on]
Thanks
Upvotes: 2
Views: 2764
Reputation: 7744
locals
is for when you're using render partial
.
<%= render partial: path_to_partial, locals: locals_hash %>
If you're just using render
, you should do this:
<%= render path_to_view, locals_hash %>
Which in your case would be:
<%= render 'favorite_things', f: f %>
Upvotes: 9