ruby-on-rails - find_resource - activeadmin scope
具有has_many問題的ActiveAdmin; 未定義的方法'new_record?' (2)
轉到您的食譜模型並添加以下行
accepts_nested_attributes_for :steps
該行是formtastic,而不是主動管理員所必需的。 檢查https://github.com/justinfrench/formtastic以獲取formtastic文檔
我正在嘗試為與Step具有has_many關係的Recipe模型自定義ActiveAdmin表單。
class Recipe < ActiveRecord::Base
has_many :steps
end
class Step < ActiveRecord::Base
acts_as_list :scope => :recipe
belongs_to :recipe
end
我在與此相關的ActiveAdmin文件中有以下內容:
form do |f|
f.has_many :steps do |ing_f|
ing_f.inputs
end
end
我嘗試加載表單時拋出以下錯誤:
未定義的方法`new_record?' 為零:NilClass
到目前為止,我已經將它與has_many方法隔離開了但是我已經迷失了。 任何建議和幫助將不勝感激!
class Recipe < ActiveRecord::Base
attr_accessible :step_attributes
has_many :steps
accepts_nested_attributes_for :steps
end