Creating an Admin directory in Rails

Posted by matsko on Stack Overflow See other posts from Stack Overflow or by matsko
Published on 2010-06-03T06:45:31Z Indexed on 2010/06/03 8:14 UTC
Read the original article Hit count: 334

I've been developing the CMS backend for a website for a few weeks now. The idea is to craft everything in the backend first so that it can manage the database and information that will be displayed on the main website.

As of now, I currently have all my code setup in the normal rails MVC structure. So the users admin is /users and videos is /videos.

My plans are to take the code for this and move it to a /admin directory. So the two controllers above would need to be accessed by /admin/users and /admin/videos. I'm not sure how todo the ruote (adding the /admin as a prefix) nor am I sure about how to manage the logic. What I'm thinking of doing is setting up an additional 'middle' controller that somehow gets nested between the ApplicationControler and the targetted controller when the /admin directory is accessed. This way, any additional flags and overloaded methods can be spawned for the /admin section only (I believe I could use a filter too for this).

If that were to work, then the next issue would be separating the views logic (but that would just be renaming folders and so on).

Either I do it that way or I have two rails instances that share the MVC code between them (and I guess the database too), but I fear that would cause lots of duplication errors.

Any ideas as to how I should go about doing this?

Many thanks!

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about ruby