Many-to-Many Association with Formtastic not working for me
My use case is a bit more complicated than the one shown in RailsCasts.
I get an unknown attribute: user error.
Issues and users are related by a many-to-many through another model. I HAVE specified the accepts_nested_attributes_for in my Issue model.
My view code:
<% semantic_form_for @issue do |form| %>
<% form.inputs do %>
<%= form.input :description, :input_html => { :rows => 5, :cols => 1, :class => 'autogrow' } %>
<%= form.input :location %>
<%= form.input :issue_type %>
<% end %>
<% form.inputs :for => :user do开发者_开发百科 |user_form| %>
<%= user_form.input :email %>
<% end %>
<% form.buttons do %>
<%= form.commit_button "Submit" %>
<% end %>
<% end %>
My Controller code:
def create
@issue = Issue.new(params[:issue])
if @issue.save
flash[:notice] = "Thank you"
else
render :action => 'new'
end
end
Any ideas? Thanks!
Try using @user
instead of :user
in the user_form.
精彩评论