Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Backend administration in 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.

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.

like image 855
srboisvert Avatar asked Sep 20 '08 08:09

srboisvert


People also ask

Can Ruby on Rails be used for backend?

Ruby on Rails is used as a backend framework for web applications. It's known for efficiency and scalability. You can write rich functionality with much fewer lines of code as opposed to what you'd need in Java or Node.

Is Ruby on Rails backend or frontend?

9. Ruby On Rails Covers Front And Back-End. This language is pretty unique in that it covers both the front- and backend, meaning that as a Ruby on Rails developer you can describe yourself as truly full stack.

Is rails good for backend?

Considering this, one such effective development tool that enhances the backend of your application is Ruby on Rails. Offering an accurate infrastructure for developers to work within the framework, Ruby helps developers ease mundane tasks quickly.


2 Answers

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

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

Which will create routes admin_customers, new_admin_customers, etc.

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 

And make this inhert from your ApplicationController:

class Admin::CustomersController < Admin::AdminController 

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.

like image 191
Laurie Young Avatar answered Oct 19 '22 16:10

Laurie Young


Do check out active_admin at https://github.com/gregbell/active_admin.

like image 43
phoet Avatar answered Oct 19 '22 16:10

phoet