Ruby on Rails 中的后端管理
我想为我在最后一刻附加的 Ruby on Rails 应用程序构建一个真正快速且肮脏的管理后端。 我研究过 activescaffold 和 Streamlined,认为它们都非常有吸引力,而且运行起来应该很简单,但我不太明白如何将其中任何一个设置为后端管理页面。 它们似乎被设计为像标准 Ruby on Rails 生成器/支架一样工作,用于创建具有模型-视图-控制器-表名称对应关系的可见前端。
当播放器已在使用中并且您希望尽可能避免影响其任何相关文件时,如何创建 admin_players 界面?
管理员无法使用原始资源的显示、编辑和索引。
I'd like to build a real quick and dirty administrative backend for a Ruby on Rails application I have been attached to at the last minute. I've looked at activescaffold and streamlined and think they are both very attractive and they should be simple to get running, but I don't quite understand how to set up either one as a backend administration page. They seem designed to work like standard Ruby on Rails generators/scaffolds for creating visible front ends with model-view-controller-table name correspondence.
How do you create a admin_players interface when players is already in use and you want to avoid, as much as possible, affecting any of its related files?
The show, edit and index of the original resource are not usuable for the administrator.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用 https://github.com/sferik/rails_admin。
Use https://github.com/sferik/rails_admin.
我非常广泛地使用 Streamlined。
为了让 Streamline 工作,您创建自己的控制器 - 这样您实际上可以完全独立于应用程序的其余部分来运行它,您甚至可以在单独的“admin”文件夹和命名空间中运行它,可以使用 。
这是最近应用程序中的客户控制器:
I have used Streamlined pretty extensively.
To get Streamline working you create your own controllers - so you can actually run it completely apart from the rest of your application, and you can even run it in a separate 'admin' folder and namespace that can be secured with .
Here is the Customers controller from a recent app:
我认为命名空间是解决您遇到的问题的方法:
它将创建路由
admin_customers
、new_admin_customers
等。然后在
app/controller
内目录您可以有一个admin
目录。 在您的 admin 目录中,创建一个管理控制器:然后创建一个管理客户控制器:
并使其继承于您的 ApplicationController:
这将在
app/views/admin/customers
中查找视图并且预计布局位于
app/views/layouts/admin.html.erb
中。然后,您可以使用您喜欢的任何插件或代码来实际执行管理、简化、ActiveScaffold,以及我个人喜欢使用
resourcecs_controller
的任何内容,因为如果您使用 REST 风格的架构,强迫自己走这条路可以在其他地方节省大量时间。 不过,如果您继承了该应用程序,那么现在还没有什么意义。I think namespaces is the solution to the problem you have here:
Which will create routes
admin_customers
,new_admin_customers
, etc.Then inside the
app/controller
directory you can have anadmin
directory. Inside your admin directory, create an admin controller:Then create an admin customers controller:
And make this inhert from your ApplicationController:
This will look for views in
app/views/admin/customers
and will expect a layout in
app/views/layouts/admin.html.erb
.You can then use whichever plugin or code you like to actually do your administration, streamline, ActiveScaffold, whatever personally I like to use
resourcecs_controller
, as it saves you a lot of time if you use a REST style architecture, and forcing yourself down that route can save a lot of time elsewhere. Though if you inherited the application that's a moot point by now.请查看 https://github.com/gregbell/active_admin 上的 active_admin。
Do check out active_admin at https://github.com/gregbell/active_admin.