开发者

Many-to-Many Association with Formtastic not working for me

开发者 https://www.devze.com 2023-01-24 22:55 出处:网络
My use case is a bit more complicated than the one shown in RailsCasts. I get an unknown attribute: user error.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消