Skip to content

Conditional Columns in the index page (CanCan)

koenhandekyn edited this page Mar 5, 2012 · 1 revision

to hide columns in the index page based on a CanCan ability simply add the condition on the column (here unless current_user.owner_id?)

index do
  column :email
  column :owner, :sortable => :owner_id unless current_user.owner_id?
  column :lessee, :sortable => :lessee_id unless current_user.lessee_id?
  column :admin
  default_actions
end
Clone this wiki locally