views:

90

answers:

1

In rails I am making a "blog" to help me learn. I was wondering how I could incorporate the editing, creating, and deletion of Users and Posts in my admin controller. I would also include deleting comments in there too. So far I have Users, Admin (basically just to login/control everything),Comments, and posts. So how could I combine all of those into one Admin panel?

+2  A: 

A controller should be per resource. Instead you could put multiple controllers under Admin namespace so that you can use admin/posts kind of URL. However, this way you'll have to write all your controller and view logic twice - once for admin, once for regular users. Combining any pages into "one panel" has nothing to do with your choice of controller structure. You will simply put links on a sidebar or on top of that panel, regardless of where the links will end up pointing to.

The easiest may be to allow editing/deleting resources conditionally, based on authorization. This way, instead of being confined to a panel you can be browsing the site like a regular user, except you'll see a few more buttons and have ability to edit/delete things. This means you can use all your already-written views and controllers.

hakunin
Thanks, I never really thought about it that way.
Deuces