I guess this is a newbie question, but what is the syntax in a form to show contents of fields not as a text box/area, but rather like label would appear.
<% form_for @user do |f| %>
<% f.fields_for :user_ingreds do |builder| %>
<p>
<%= builder.??? %>
</p>
<% end %>
<% end%>
user has_many :user_ingreds
and accepts_nested_attributes_for :user_ingreds
.
Basically I want to make a list of user_ingreds
where the user can't edit the data but can remove the record from the list via a button.
However the fields_for builder doesn't recognize a direct call to to the fields in UserIngred
model (ie, builder.user_id
throws and error.
If you want to make a non-editable list of the ingreds with a button to remove them, then don't make a form.
Instead, display your data and a button beside them created with link_to and pointing to your delete function.
If ever you want to really display the content of your form variable, you can access it this way:
builder.object.user_i
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.