Remove navigation menu item for model without removing ability to manage in RailsAdmin and CanCan?

1.3k Views Asked by At

So I have a model (Image) that belongs to another model (Product), and I want to allow a user to manage both of these two types of models, but I don't want to list the model in the navigation menu in RailsAdmin.

Basically of these two I only want Product to be visible in the navigation menu, while allowing the user to still crud their images within the edit/add form of a Product.

Is this possible with CanCan? Or do I need to use CSS to hide these navigation items?

5

There are 5 best solutions below

1
On BEST ANSWER

According to this issue, and this issue your only valid approach would be the CSS approach

0
On

in your model:

rails_admin do
  visible false
end

no need to edit your rails_admin.rb file.

0
On

I had same issue. fixed using this css

li[data-model="event_date"] {
display:none !important;
}
2
On
   config.model Team do
     visible false
    end
0
On

I had the same issue, and unfortunately I haven't found any proper solution. The only workaround was to hack Rails Admin using javascript.

So, to hide the model Image from the navigation menu I added this code in 'app/assets/javascripts/rails_admin/custom/ui.js':

$(document).on('rails_admin.dom_ready', function() {
  $('ul.nav-pills li[data-model="image"]').hide();
});