ruby on rails - ActiveAdmin hide Delete action by condition -
i have problem.
in activeadmin need hide delete action condition.
i did #index
page. don't know how trick #show page.
here's code:
index selectable_column column :id |package| link_to package.id, admin_subscription_package_path(package) end column :title column :plan_status column :duration |package| if package.duration == 1 "#{package.duration} day" else "#{package.duration} days" end end column 'price (usd)', :price |package| number_to_currency(package.price, locale: :en) end column :actions |object| raw( %( #{link_to 'view', admin_subscription_package_path(object)} #{(link_to 'delete', admin_subscription_package_path(object), method: :delete) unless object.active_subscription? } #{link_to 'edit', edit_admin_subscription_package_path(object)} ) ) end end
or maybe can more useful pages @ once.
use action_item purpose:
activeadmin.register mymodel actions :index, :show, :new, :create, :edit, :update, :destroy action_item only: :show if condition link_to "delete whatever", {action: :destroy}, method: :delete, confirm: 'something deleted forever. sure?' end end end
Comments
Post a Comment