Enrai
Enrai

Reputation: 593

Overriding the default views in RailsAdmin

I am using Ruby on Rails 4.2.1 with RailsAdmin. The gem works excellent, but I have the requirement that the layout of the admin panel and the forms must look different than what is generated by default. For example, the navigation should be horizontal top, the forms should order the fields in two columns.

So far I haven't find a way to copy the views locally and modify them (like in Devise for example). I have tried to replicate the views manually in the respective path under my views folder by copying the original views, but I got problems with the helper methods that are part of RailsAdmin not being accessible from my views.

I dug deeper and found that there is a task copy_views, it was referred to in questions for the older versions of the gem, but if I try to use it now rake rails_admin:copy_views, it is not available anymore.

Am I doing something wrong, or is there another way to do this?

Upvotes: 1

Views: 1041

Answers (1)

Dmitry Polyakovsky
Dmitry Polyakovsky

Reputation: 1585

You can create folders in your app

app/views/rails_admin/main for https://github.com/sferik/rails_admin/tree/master/app/views/rails_admin/main

app/views/layouts/rails_admin/ for https://github.com/sferik/rails_admin/tree/master/app/views/layouts/rails_admin

Put modified files there. It can get a little messy and you will need to update the files if the gem changes.

Upvotes: 1

Related Questions