1

我在使用 ActiveAdmin 时遇到问题。

我有以下型号:

模板.rb

class Template < ActiveRecord::Base
  belongs_to :category
  has_many :template_questions
  has_many :questionnaires
  attr_accessible :category, :string
  accepts_nested_attributes_for :template_questions
end

模板问题.rb

class TemplateQuestion < ActiveRecord::Base
  belongs_to :template
  attr_accessible :number, :question
end

而这个活跃的管理资源

ActiveAdmin.register Template do
  form do |f|
    f.inputs "Details" do
      f.input :title
      f.input :category
    end
    f.inputs "Questions" do
      f.has_many  :template_questions do |j|
        j.input :question
      end
    end
    f.buttons
  end
end

当我在 ActiveAdmin 界面中的表单上时,我正确地看到了标题和类别的字段,然后在问题部分我得到一个按钮来添加一个问题,但是当单击它时它什么也不做。

知道我做错了什么吗?谢谢!

4

2 回答 2

1

您通常需要将属性添加到 attr_accessible,所以让我们添加

attr_accessible :category, :string, :template_questions_attributes
于 2012-07-13T02:36:16.733 回答
0

我一直在敲墙,直到我在活动管理员 github 上看到一个未解决的问题

解决方案是从活动管理员 0.5.1 回滚到 0.5.0

于 2013-03-06T15:46:51.813 回答