Remove duplicate items from the left menu on rails_admin with this configuration

Img caption: stackoverflow

I recently had an issue with Rails Admin, which was displaying duplicate models in the left hand side menu. It was something that I had not encountered before, and it turned out, it was a rare occasion, as I could not find that much coverage about it. I also saw that this unanswered question related to this problem was published more than a year and a half ago in StackOverflow. This is the reason why I decided to write this post.

As you may already know, when you install rails_admin in a Rails application, you are going to get a rails_admin.rb file in your config/initializers directory. This is the place to place all your configurations that you have regarding the options and features that rails_admin provides. It turned out that removing the display of duplicate items in the left menu was possible by mentioning specifically the names of the models in this initializer file:

config.included_models = ["FirstModel", "SecondModel", "ThirdModel"]

This trivial configuration makes sure rails_admin knows the models that it needs to display, and not bother to figure this out by itself.

I hope you find this article helpful.

Happy coding!