# Re: Newbie CMS question

**URL:** <https://www.ruby-forum.com/t/re-newbie-cms-question/99789>\
**Category:** Rails\
**Created:** [July 25, 2006, 3:58pm UTC](https://www.ruby-forum.com/t/re-newbie-cms-question/99789 "2006-07-25T15:58:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 25, 2006, 3:58pm UTC](https://www.ruby-forum.com/t/re-newbie-cms-question/99789/1 "2006-07-25T15:58:46Z")

</div>

That does make a lot more sense than the way I was trying!

Thanks very much, I’ll give it a bash and see how I get on. 🙂

Henry

Henry B.: Music Production - Audio Engineering - Web D.

- Session Drumming  
Contact: [www.henrybourne.co.uk](http://www.henrybourne.co.uk) - removed\_email\_address@domain.invalid - 07740 192427

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 25, 2006, 11:32pm UTC](https://www.ruby-forum.com/t/re-newbie-cms-question/99789/2 "2006-07-25T23:32:14Z")

</div>

Hey Henry,  
If your still there. I just wanted to say ‘that is only one way of  
doing it’ one more time. To be honest its probably not the most common  
way that I have seen in other projects but its my approach.

Probably a more common way would be to have an admin directory in your  
controllers. So you would have a audio\_items\_controller and then you  
would have an admin/audio\_items\_controller. That way you could really  
easily go to www.yoursite/admin and you would be at your admin interface  
and cruse around in there going to different controllers and just leave  
the controllers outside of that directory to mostly do public display  
stuff.

there is also more to that approach, but its pretty simple and how I  
started out. It might be easier to deal with. And there are good  
examples of that kind of structure being used all over. Check out just  
about any OS rails app and look into the controller directory and you  
will see an admin folder with repeating controllers that have been made  
for editing and stuff in it, while the top level controllers do mostly  
display stuff.

I got worried there because I didn’t want to give you the impression  
that the way I described was what most of the rails apps are doing  
today. Its the way I find most sensible and use in my own work. If I  
had been less hypnotized by my own genius 😉 when I wrote my first  
response I would have probably told you to make an admin module like I  
mentioned above.

The best way to get some ideas is by looking at how other guys are doing  
it. I would suggest looking around in mephisto or typo. You’ll learn  
alot.

best wishes,  
john

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 26, 2006, 11:27am UTC](https://www.ruby-forum.com/t/re-newbie-cms-question/99789/3 "2006-07-26T11:27:58Z")

</div>

Thanks very much for your help! What you just described is the kind of  
thing I was trying to do in the first place, but I couldn’t quite get my  
head around doing it. I still have a few related issues with rails in  
general that are throwing me a bit and would greatly appreciate your  
advice if that’s ok?

In the example of my site, I make a model ‘web\_item’ which also creates  
a database ‘web\_items’ and has the class name ‘WebItem’. Now at the  
moment, I’m kind of thinking that I also have to make a controller  
called ‘web\_items’. What’s throwing me is the depot example in the AWD  
book that just has the one main ‘Products’ database and a ‘products’  
controller thats deals with that.

I guess what I’m trying to say is, can I have any number of controllers  
dealing with a certain model? So in the example of my site again, can I  
have a controller called ‘web’ which can get data from the ‘web\_items’  
model and display it using the ‘web’ view which would be what the public  
sees. Then also like you suggested an admin controller folder containing  
controllers which can access the same model but use different views and  
actions and require authorisation to log in? And could I generate a  
scaffold from each of these to help me get started?

Thanks  
Henry

john wrote:

> Hey Henry,  
> If your still there. I just wanted to say ‘that is only one way of  
> doing it’ one more time. To be honest its probably not the most common  
> way that I have seen in other projects but its my approach.
> 
> Probably a more common way would be to have an admin directory in your  
> controllers. So you would have a audio\_items\_controller and then you  
> would have an admin/audio\_items\_controller. That way you could really  
> easily go to www.yoursite/admin and you would be at your admin interface  
> and cruse around in there going to different controllers and just leave  
> the controllers outside of that directory to mostly do public display  
> stuff.
> 
> there is also more to that approach, but its pretty simple and how I  
> started out. It might be easier to deal with. And there are good  
> examples of that kind of structure being used all over. Check out just  
> about any OS rails app and look into the controller directory and you  
> will see an admin folder with repeating controllers that have been made  
> for editing and stuff in it, while the top level controllers do mostly  
> display stuff.
> 
> I got worried there because I didn’t want to give you the impression  
> that the way I described was what most of the rails apps are doing  
> today. Its the way I find most sensible and use in my own work. If I  
> had been less hypnotized by my own genius 😉 when I wrote my first  
> response I would have probably told you to make an admin module like I  
> mentioned above.
> 
> The best way to get some ideas is by looking at how other guys are doing  
> it. I would suggest looking around in mephisto or typo. You’ll learn  
> alot.
> 
> best wishes,  
> john

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 26, 2006, 12:18pm UTC](https://www.ruby-forum.com/t/re-newbie-cms-question/99789/4 "2006-07-26T12:18:54Z")

</div>

Henry B. wrote:

> I guess what I’m trying to say is, can I have any number of controllers  
> dealing with a certain model? So in the example of my site again, can I  
> have a controller called ‘web’ which can get data from the ‘web\_items’  
> model and display it using the ‘web’ view which would be what the public  
> sees. Then also like you suggested an admin controller folder containing  
> controllers which can access the same model but use different views and  
> actions and require authorisation to log in? And could I generate a  
> scaffold from each of these to help me get started?
> 
> Thanks  
> Henry

Thats exactly right. You can call your controllers whatever you want  
and have as many as you want too. There is nothing that really binds a  
controller to a model. It does tend to happen though, that you have  
controllers and models with similar concepts in mind. So you usually do  
have your WebItem model (whos job is to take care of its state and  
provide class methods for finding WebItems in the DB and stuff) and then  
a WebItemsController (who’s job is to control or direct or delegate the  
flow of information between the WebItem models and the WebItem views  
based on the request that comes in through the server). But this is  
just a convenient pattern for organizing things. It just tends to keep  
things clear. But it is in no way necessary. You can be as creative as  
you would like.

To be honest if you really wanted to have a single admin\_controller be  
the one controller for all of your models it would work fine. There is  
nothing stopping you from filling up a controller with every action  
under the sun. So you could have made actions like edit\_audio\_item and  
edit\_web\_item and basically crammed two scaffolding like sets of  
methods into the same controller (each working on either web\_items or  
audio\_items). Then in the future, any time you wanted to add a new  
model that needed to be edited you could shoehorn another set of actions  
in there. But this is clearly not a good way to keep things in good  
order. But anyway yeah, controllers aren’t tightly bound to models like  
they are to views or anything.

I hope that helps (or at least makes sense).

---

<div class="post-metadata">

**Author:** ![henry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/df705f/32.png) [@henry](https://www.ruby-forum.com/u/henry)\
**Post date:** [July 26, 2006, 12:29pm UTC](https://www.ruby-forum.com/t/re-newbie-cms-question/99789/5 "2006-07-26T12:29:52Z")

</div>

Spot on! Thanks very much! That’s defintely cleared things up for me.

I’ve just been having a play around, and everything seems to be coming  
together now! I’ll defnintely be coming back here if I have any other  
problems in the future.

Thanks again! 🙂  
Henry
