-
Notifications
You must be signed in to change notification settings - Fork 123
Open
Description
Update the active admin file (notice the comments in the code).
here is my example:
ActiveAdmin.register Survey::Survey do
permit_params :name, :attempts_number, :description, :finished, :active #mandatory for rails 4 and newer versions of active admin
menu :label => I18n.t("surveys")
filter :name,
:as => :select,
:collection => proc {
Survey::Survey.select("distinct(name)").collect { |c|
[c.name, c.name]
}
}
filter :active #,
#:as => :select,
#:collection => ["true", "false"]
# no needed activeadmin detects a boolean as yes or not automatically
filter :created_at
index do
column :name
column :description
column :active
column :attempts_number
column :finished
column :created_at
actions #default_actions
end
form do |f|
f.inputs I18n.t("survey_details") do
f.input :name
f.input :description
f.input :active #, :as => :select, :collection => ["true", "false"] no needed activeadmin detects a boolean input as checkbox
f.input :attempts_number
end
f.inputs I18n.t("questions") do
f.has_many :questions do |q|
q.input :text
q.has_many :options do |a|
a.input :text
a.input :correct
end
end
end
f.actions #buttons
end
end
There is another thing, the questions are not saving correctly, you can create a survey but when you save it, the questions were not saved, or when you try to save the survey a validation says " Survey without questions cannot be activated" in the active field and the questions that you've made, disappeared
I'm using active admin 1.0.0 pre 4
Rails 4.2.6
Ruby 2.20
the gsurvey gem "survey", "~> 0.1"
Metadata
Metadata
Assignees
Labels
No labels