tin tin
tin tin

Reputation: 372

Rails Active Admin : How to have a "Approve" button in the active admin index view

I am just exploring active admin but got stuck in adding an action button ( approve / reject ) in the index view. Here is the code snippet. In, app/admin/user.rb

index do
    selectable_column
    id_column
    column :email
    column :current_sign_in_at
    column :sign_in_count
    column :created_at
    column '' do 
      # Here is where I need a button to "Approve / Reject" the user(s).
    end
    actions
end

Upvotes: 0

Views: 634

Answers (2)

MilesStanfield
MilesStanfield

Reputation: 4639

You got stuck adding an action button ...

Here's how to do it

# app/admin/some_class.rb
ActiveAdmin.register SomeClass do

  action_item :approve, only: :index do
    link_to "Approve", some_path
  end

  index do
    selectable_column
    id_column
    column :email
    column :current_sign_in_at
    column :sign_in_count
    column :created_at
    actions
  end
end

Upvotes: 1

margo
margo

Reputation: 2927

You can use link_to inside the block

column "Approve / Reject" do 
  link_to("Approve / Reject", some_path)
end

Upvotes: 1

Related Questions