mercredi 17 août 2016

show custom records in activeadmin index page

I want to show venues in a conditional approach on index page in activeadmin like if a current_admin_user role would be super_admin then he can view all records, if current_admin_user role would be city_manager then he can also view all records but if current_admin_user role would be venue_manager then he can only view there venues.

I am not able to do this, I have venues as per conditional approach but let me know how to use venues variable to list out venues on index page

index do 
    if current_admin_user.is_super_admin?
        venues = Venue.all
    elsif current_admin_user.is_city_manager?
        venues = Venue.all
    elsif current_admin_user.is_venue_manager?  
        venues = current_admin_user.user.venues
    else
        venues = Venue.all
    end
    selectable_column
    id_column
    column :title    
    actions
end

Thanks In Advance.

Aucun commentaire:

Enregistrer un commentaire