我遇到ActiveAdmin和嵌套表单的问题:当我用一些回复创建一个新问题时,我收到一个错误(问题不能为空)。但是,如果我创建一个问题然后,在更新时,我添加一些回复一切顺利。
任何人都可以帮助我吗?
这是我的代码
# models/question.rb
class Question < ActiveRecord::Base
attr_accessible :points, :text, :replies_attributes
# RELATIONS
has_many :replies
accepts_nested_attributes_for :replies
end
# models/reply.rb
class Reply < ActiveRecord::Base
attr_accessible :correct, :question_id, :text, :question
# VALIDATIONS
validates_presence_of :text, :question_id
# RELATIONS
belongs_to :question
end
# admin/question.rb
ActiveAdmin.register Question do
form do |f|
f.inputs "Details" do
f.input :text
f.input :points
end
f.inputs do
f.has_many :replies do |rp|
rp.input :text
rp.input :correct
end
end
f.actions
end
end