Admin section in rails

Hello guys

i am a newbie in rails and need your guidance in the design of the app.

i am working on a task of creating a store application. its a bit diiferent as people can register as customer and also as seller (like in ebay) and there is also a superadmin

so the levels are 1.superadmin 2.sellers 3.customers

i am using rails 2.0.2 and was looking at how to create a admin section for such app.

i saw railscast no 19,20,21 by ryan bates for creating admin section he does create any admin folder and hides the links the views on the basis of if admin had logged in

I also saw video by akitaonrails where he creates seperate admin folder and copies the views

specifically in my case the difference in views for products for different levels wud be

1. superadmin : all products by all sellers (all actions) 2. seller : all products added by him only (all actions allowed) 3. customers :all products by all sellers (only view )

pls guide me which approch shud i use

Regards Jagdish Rao

I'm very new too, but I did recently learn about using namespaces to create the admin section if you want to keep it separate. It sounds like the "REST" thing to do anyway. You might have a look at the article I looked at and see if its applicable. I'm sure others know better though. :slight_smile:

You can also just use a before_filter like (in my app, anyone can see anything, but only certain roles can affect certain things, like Users):

class UsersController < ApplicationController   layout 'testbase.html.haml'

  before_filter :login_required   before_filter :check_administrator_role, :except => [:index, :show]

  blah blah blah end

The various views restrict the links and buttons so people can't see what they can't do, but the controller enforces it as well to keep out the URL manglers.