Sha256: e88b7d63775093669c3c38e88ebdcea8fa01bb5e515cbd57d6cacbba7060a8f0

Contents?: true

Size: 1.65 KB

Versions: 8

Compression:

Stored size: 1.65 KB

Contents

module Qwester

  ActiveAdmin.register Answer do
    
    menu_label = 'Answers'
    menu_label = "Qwester #{menu_label}" unless Qwester.active_admin_menu
    menu :parent => Qwester.active_admin_menu, :label => menu_label

    actions :all, :except => [:edit, :new]
    config.batch_actions = false
    
    filter :question
    filter :value
    filter :created_at
    filter :updated_at
    filter :position
    filter :weighting, :label => Answer.weighting_alias_name.humanize
    

    index do
      column :id
      column :value
      column 'Question (edit answer via question)', :question do |answer|
        link_to(answer.question.title, edit_admin_qwester_question_path(answer.question)) if answer.question
      end
      column Answer.weighting_alias_name.humanize, :weighting
      column :position      
      default_actions
    end
    
    show do |ad|
      attributes_table do
        row :question
        row :value
        row :updated_at
        row :position
        row Answer.weighting_alias_name.humanize do |answer|
          answer.weighting
        end
      end
      active_admin_comments
    end
    
    member_action :move_up do
      answer = Answer.find(params[:id])
      answer.move_higher
      redirect_to admin_qwester_question_path(answer.question)
    end
    
    member_action :move_down do
      answer = Answer.find(params[:id])
      answer.move_lower
      redirect_to admin_qwester_question_path(answer.question)      
    end
    
    member_action :remove do
      answer = Answer.find(params[:id])
      answer.destroy
      redirect_to admin_qwester_question_path(answer.question) 
    end


  end if defined?(ActiveAdmin)

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
qwester-0.5.0 lib/active_admin/admin/answers.rb
qwester-0.4.0 lib/active_admin/admin/answers.rb
qwester-0.3.5 lib/active_admin/admin/answers.rb
qwester-0.3.4 lib/active_admin/admin/answers.rb
qwester-0.3.3 lib/active_admin/admin/answers.rb
qwester-0.3.2 lib/active_admin/admin/answers.rb
qwester-0.3.1 lib/active_admin/admin/answers.rb
qwester-0.3.0 lib/active_admin/admin/answers.rb