# Admin section in rails

**URL:** <https://www.ruby-forum.com/t/admin-section-in-rails/134179>\
**Category:** Rails\
**Created:** [April 8, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/admin-section-in-rails/134179 "2008-04-08T17:34:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jags](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jags](https://www.ruby-forum.com/u/jags)\
**Post date:** [April 8, 2008, 5:34pm UTC](https://www.ruby-forum.com/t/admin-section-in-rails/134179/1 "2008-04-08T17:34:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jags](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jags](https://www.ruby-forum.com/u/jags)\
**Post date:** [April 8, 2008, 7:42pm UTC](https://www.ruby-forum.com/t/admin-section-in-rails/134179/2 "2008-04-08T19:42:43Z")

</div>

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. 🙂

> **[Rolling with Rails 2.0 - The First Full Tutorial - Part 1 | AkitaOnRails.com](https://www.akitaonrails.com/2007/12/12/rolling-with-rails-2-0-the-first-full-tutorial)**
>
> for brazilians: click here.
> I am very happy to see that my Rails 2.0 Screencast was very well received. More than 1,500 unique visitors watched it...

---

<div class="post-metadata">

**Author:** ![jags](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/dc4da7/32.png) [@jags](https://www.ruby-forum.com/u/jags)\
**Post date:** [April 8, 2008, 7:57pm UTC](https://www.ruby-forum.com/t/admin-section-in-rails/134179/3 "2008-04-08T19:57:43Z")

</div>

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.
