重写RailsAdmin中的默认视图。

时间:2023-01-27 23:35:20

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.

我使用Ruby on Rails 4.2.1和RailsAdmin。gem工作出色,但我有一个要求,即管理面板和表单的布局必须与默认生成的外观不同。例如,导航应该是水平顶部,表单应该在两列中命令字段。

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.

到目前为止,我还没有找到复制本地视图和修改视图的方法(比如在设计中)。我尝试在我的视图文件夹下通过复制原始视图,在各自的路径中手动复制视图,但是我遇到了一些辅助方法的问题,这些方法是RailsAdmin的一部分,不能从我的视图中访问。

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.

我深入挖掘,发现有一个任务copy_views,它是在关于gem的旧版本的问题中提到的,但是如果我现在尝试使用它,就会发现rails_admin:copy_views,它已经不再可用了。

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

我是不是做错了什么,或者还有别的方法吗?

1 个解决方案

#1


0  

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 / rails_admin /主要为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

app / views /布局/ rails_admin / 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.

把修改的文件。它可能会有点混乱,如果gem发生变化,您将需要更新文件。

#1


0  

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 / rails_admin /主要为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

app / views /布局/ rails_admin / 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.

把修改的文件。它可能会有点混乱,如果gem发生变化,您将需要更新文件。