2012-07-12 54 views
1

我遇到ActiveAdmin問題。ActiveAdmin表單問題(has_many)

我有以下型號:

template.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 

template_question.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界面中的表單正確地顯示了標題和類別的字段,然後在問題部分我得到一個按鈕來添加一個問題,但點擊它時什麼也不做。

任何想法我做錯了什麼?謝謝!

回答

1

您通常需要添加屬性attr_accessible,所以讓我們來添加

attr_accessible :category, :string, :template_questions_attributes 
+0

這不是我的主要問題,原來是與JavaScript的東西。但是非常感謝,這對我後來的確幫助很大! – 2012-07-13 22:47:29

+2

我遇到同樣的問題。你能告訴我們什麼是「JavaScript的東西」是什麼? – jeem 2013-02-05 12:25:28

0

我一直在敲打我的頭掛在牆上,直到我上主動管理的github

解決方案看到了open issue是從活動管理員0.5.1回滾到0.5.0