70820

Active Admin: Multiple Actions in same column similar to View, Edit, Delete

Question:

I am using active admin gem to have a admin console for my ruby on rails application. I am having a problem where i want to have multiple custom actions to every item on index page just like View,Edit, Delete. But when adding custom action only the last one is displayed instead of all.

index do column 'Instructor Name',:user column 'Email Address', :email column 'Phone Number', :phone column 'website', link_to 'google', 'www.google.com' column :bio actions defaults: false do |application| if application.user.instructor == 2 button_to 'Disapprove', instructor_deny_user_path(application.user.id), method: :put else button_to 'Approve', instructor_approve_user_path(application.user.id), method: :put end link_to "resume",getresume_instructor_applications_path(id: application.id) end end

Only resume link is shown instead of Approve/Disprove and resume

What am i doing wrong

Answer1:

If you have ActiveAdmin >= 1.0.0.preX, you can do this:

actions defaults: false do |application| if application.user.instructor == 2 action_item 'Disapprove', instructor_deny_user_path(application.user.id), method: :put else action_item 'Approve', instructor_approve_user_path(application.user.id), method: :put end action_item "resume", getresume_instructor_applications_path(id: application.id) end

If you use a 0.6.x:

actions defaults: false do |application| if application.user.instructor == 2 text_node link_to 'Disapprove', instructor_deny_user_path(application.user.id), method: :put else text_node link_to 'Approve', instructor_approve_user_path(application.user.id), method: :put end link_to "resume", getresume_instructor_applications_path(id: application.id) end

Answer2:

Try put your approve/disapprove links in columns like this,

column 'action' do |application| application.user.instructor == 2 ? button_to 'Disapprove', instructor_deny_user_path(application.user.id), method: :put : button_to 'Approve', instructor_approve_user_path(application.user.id), method: :put end

And Default link for resume as it is.

actions defaults: false do |application| link_to "resume",getresume_instructor_applications_path(id: application.id) end

Recommend

  • Cannot Assign to 'Money' Because It Is a 'Method Group'
  • nodejs async: multiple dependant HTTP API calls
  • What is considered a statement in C++?
  • How to clean up the data from this webscraping script?
  • Giving right align to numeric data in datatables
  • How to make Rails do not ignore trailing slashes in the routes?
  • Custom routes with rails 3.1
  • Using Resque and resque_mailer to send emails raises Routing error
  • css background images not always displayed
  • You tube videos are not playing
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • Implementing “partial void” in VB
  • How do I include a SWC in an AS2 Flash project?
  • Sending HTML Form Data to Spring REST Web Service
  • How to add a focus style to an editable ComboBox in WPF
  • How do I superscript characters in a UIButton?
  • Groovy: Unexpected token “:”
  • How do I access an unhandled exception in an MVC Error view?
  • AJAX Html Editor Extender upload image appearing blank
  • How to run “Deployd” on port 80 instead of port 5000 in webserver.
  • Email verification using google app script and google forms
  • Replace value with Factor in r data.table
  • Typescript - Unable to get 'import' statement to function
  • Meteor: Do Something On Email Verification Confirmation
  • Cannot resolve symbol 'MyApi'
  • How to access EntityManager inside Entity class in EJB3
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Email format validation in mvc3 view
  • How to get address from latitude and longitude android google map v2 [duplicate]
  • Is there any way to access browser form field suggestions from JavaScript?
  • Is my CUDA kernel really runs on device or is being mistekenly executed by host in emulation?
  • Window Size for Mac application
  • sending/ receiving email in Java
  • what is the difference between the asp.net mvc application and asp.net web application
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • using HTMLImports.whenReady not working in chrome
  • Authorize attributes not working in MVC 4
  • Busy indicator not showing up in wpf window [duplicate]
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF