我有两个问卷.rb是这样的:
ActiveAdmin.register Questionaire do
menu :label => proc{ I18n.t("menu.admin.questionaire") }, :priority => 25
# actions :all, :except => [:create, :destroy]
filter :role
filter :name
config.comments = false
scope :all
def new
create!
end
index do
column :id
column :name
column :role
column :description
column do |ques|
link_to t("activeadmin.questionaire.add_question"), new_admin_question_path
end
column do |ques|
link_to t("activeadmin.questionaire.show_question"), admin_questions_path
end
default_actions
end
form do |f|
f.inputs :questionaire do
f.input :id, :as => :hidden
f.input :name
f.input :role
f.input :description
end
f.actions
end
端
一个问题有很多问题,问题属于问卷。
在问题表中,我添加了这个:
t.references :questionaire
add_index :questions, :questionaire_id
但是当我点击链接时:
link_to t("activeadmin.questionaire.add_question"), new_admin_question_path
问题_id是空白的!
我如何获得questionaire_id,当点击每个问卷的每个链接添加问题时,这些问题只属于他们的问卷?
编辑: rake路线后的问题和问卷的结果:
batch_action_admin_questionaires POST /admin/questionaires/batch_action(.:format) admin/questionaires#batch_action
admin_questionaires GET /admin/questionaires(.:format) admin/questionaires#index
POST /admin/questionaires(.:format) admin/questionaires#create
new_admin_questionaire GET /admin/questionaires/new(.:format) admin/questionaires#new
edit_admin_questionaire GET /admin/questionaires/:id/edit(.:format) admin/questionaires#edit
admin_questionaire GET /admin/questionaires/:id(.:format) admin/questionaires#show
PUT /admin/questionaires/:id(.:format) admin/questionaires#update
DELETE /admin/questionaires/:id(.:format) admin/questionaires#destroy
batch_action_admin_questions POST /admin/questions/batch_action(.:format) admin/questions#batch_action
admin_questions GET /admin/questions(.:format) admin/questions#index
POST /admin/questions(.:format) admin/questions#create
new_admin_question GET /admin/questions/new(.:format) admin/questions#new
edit_admin_question GET /admin/questions/:id/edit(.:format) admin/questions#edit
admin_question GET /admin/questions/:id(.:format) admin/questions#show
PUT /admin/questions/:id(.:format) admin/questions#update
DELETE /admin/questions/:id(.:format) admin/questions#destroy