简体   繁体   中英

ActiveAdmin record activation page?

I'm working on an application for which the admin has to activate 'topics' before they are shown. The topics table simply has a column called active .

I'm using the ActiveAdmin gem for the rest of the admin panel and I also have an edit page for topics where every aspect of the topic can be changed. However, I would also like to have a secondary page for topics which would only display that title, and make it possible to activate the topic (without being able to change the other columns). I'm sure this would be more user-friendly, but I don't know how to go about it, or if it is even possible.

I have the impression that only one edit page can be made for each model.

Any ideas?

EDIT

topic.erb

class Topic < ActiveRecord::Base

  scope :pending, where(:active => false)

  validates_presence_of :title, :description, :user_id
  belongs_to :user

  has_many :solutions
  accepts_nested_attributes_for :solutions, :allow_destroy => true, :reject_if => Proc.new{|attributes| attributes["title"].blank?}

  acts_as_taggable

end

I can't try it right now myself, but I'd say you want something like this as ActiveAdmin configuration:

ActiveAdmin.register Topic do
  scope :pending

  menu :label => 'Activate Topics'

  # if you want it as submenu of 'Topic':
  # menu :parent => 'Topic'

  index do
    column :active
  end
end

Where the pending scope would be a model scope for just showing the pending (not active) topics. Like:

class Topic < ActiveRecord::Base
  scope :pending, where(:active => false)

  # ...
end

Best Regards

Tobias

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM