rails_admin navigation hide model does not work
Asked Answered
W

5

10

I have one model that I want to hide from Navigation on the left of rails_admin but it does not work. (I still want to access it, just want to hide it from the panel, so exclude does not count)

I have tried all three kind of code below but it does not work:

config.model 'Document' do
 visible false
end

from here: https://github.com/sferik/rails_admin/wiki/Navigation

As well as the code:

config.model 'Document' do
   hide_from_navigation
end

from here: http://www.verious.com/code/foca/rails_admin/

As well as the code:

config.model 'Document' do
   navigation do
      visible = false
     end
end

Can someone explain for me why ?

I have already restart the server before checking it.

Thanks!

Wilda answered 3/6, 2013 at 6:16 Comment(0)
C
4

I solved it adding the following line of code in config/initializers/rails_admin.rb:

config.excluded_models= [Document]

Instead of:

config.excluded_models = ['Document']
Candycecandystriped answered 1/7, 2016 at 1:16 Comment(0)
B
2

in your app/config/initializers/rails_admin.rb file you can add something like this and only include the models you want to show up in your navigation --

config.included_models = [ User, Region, Newsletter, Article ]
Beestings answered 7/5, 2014 at 0:50 Comment(0)
A
2

I just tested the first example :

config.model 'Document' do
 visible false
end

and it worked, the model was hidden.

Be sure to remember that you have to restart rails.

Albumenize answered 12/8, 2014 at 8:43 Comment(0)
N
1

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 Document 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="document"]').hide();
});

I hope that a better way to do this is implemented soon.

Nae answered 22/4, 2015 at 22:16 Comment(0)
J
0

in your model:

rails_admin do
  visible false
end

no need to edit your rails_admin.rb file.

Jillianjillie answered 29/8, 2021 at 9:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.