Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法有条件地隐藏资源#index上每行的“编辑”链接?
例如,假设您有User资源。当用户处于活动状态时,您可以编辑用户。但是,一旦用户停用他们的帐户,它就不再是可编辑的。用户仍应显示在索引页面上,并且仍然具有查看链接。
User
谢谢!
您可以制作列而不是 default_actions 列:
index do column :actions do |resource| links = link_to I18n.t('active_admin.view'), resource_path(resource) if resource.is_active? links += link_to I18n.t('active_admin.edit'), edit_resource_path(resource) end links end end