Ruby on Rails中的后端管理 [英] Backend administration in Ruby on Rails

查看:158
本文介绍了Ruby on Rails中的后端管理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为最后一分钟连接到的Ruby on Rails应用程序构建一个真正快速而肮脏的管理后端。我查看了主动式脚手架并进行了精简,认为它们都非常吸引人,并且应该易于运行,但是我不太了解如何将其中一个设置为后端管理页面。它们似乎像标准的Ruby on Rails生成器/脚手架一样工作,用于创建具有模型-视图-控制器-表名称对应关系的可见前端。

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.

如何创建admin_players界面,当播放器已经在使用中并且您想要尽可能避免影响其任何相关文件吗?

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.

推荐答案

我认为名称空间是解决此处问题的方法:

I think namespaces is the solution to the problem you have here:

map.namespace :admin do |admin|
    admin.resources :customers
end

将创建<$ c的路线$ c> admin_customers , new_admin_customers 等。

然后在 app / controller 目录,您可以拥有一个 admin 目录。在您的管理目录中,创建一个管理控制器:

Then inside the app/controller directory you can have an admin directory. Inside your admin directory, create an admin controller:

./script/generate rspec_controller admin/admin

class Admin::AdminController < ApplicationController

  layout "admin"
  before_filter :login_required
end

然后创建一个管理员客户控制器:

Then create an admin customers controller:

./script/generate rspec_controller admin/customers

并从您的ApplicationController中获得此继承:

And make this inhert from your ApplicationController:

class Admin::CustomersController < Admin::AdminController

这将在 app / views / admin中查找视图/ customers
,并且期望在 app / views / layouts / admin.html.erb 中进行布局。

然后,您可以使用自己喜欢的任何插件或代码进行管理,简化,ActiveScaffold,无论我个人喜欢使用 resourcecs_controller ,因为如果您使用 REST 样式体系结构并强迫自己下来会节省很多时间那条路线可以在其他地方节省很多时间。不过,如果您现在继承了该应用程序,那将是一个有争议的问题。

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.

这篇关于Ruby on Rails中的后端管理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆