Skip to content

strong parameters for active admin #41

@sutherland007

Description

@sutherland007

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions