ID = 1的文章我試圖創建一篇文章。找不到文章編號=
class Article < ActiveRecord::Base
belongs_to :article_skill
attr_accessible :articles_skill_attributes
accepts_nested_attributes_for :articles_skill
end
class ArticlesSkill < ActiveRecord::Base
attr_accessible :description, :name
has_many :articles
end
這是我在article/new.html.erb
<%= article_form.fields_for :articles_skill, @article.articles_skill do |b|%>
<label class="medium"><span class="red">*</span> Skill</label>
<%= b.select :id, options_for_select(ArticlesSkill.all.collect{|m| [m.name, m.id]}) %>
<%end%>
形式在這裏article_form
對於@article
窗體對象的建設者。
如果我嘗試保存@article
對象,則顯示此錯誤。
Couldn't find ArticlesSkill with ID=1 for Article with ID=
你有什麼試過?控制器代碼?請求的前兩行(帶有發送的參數)? – fotanus 2013-05-06 13:28:40