Including controllers within a controller

Not entirely sure if that spells out what I am trying to do.

So I am using (active) scaffolds for administration of the website. I have 4 controllers that are working well to administer their respective tables in the database using active scaffolds.

What I would like to do and I am having a time getting it to work is to have a single admin page that will call all of these controller into one page ( I would imagine we would call this includes).

I am not sure if that is how it is suppose to be done in rails but essentially I want one page where I can CRUD pages, users, categories, etc.

Active scaffolds is a pretty nice tool that will please the end-user admin and it would please me if they can administer their entire site in one convenient page.

Can I do this and if so how?

Joel Slowik wrote:

What I would like to do and I am having a time getting it to work is to have a single admin page that will call all of these controller into one page ( I would imagine we would call this includes).

It sounds like what you want is to use one of the admin page's layouts and update it with, say, a sidebar containing the choices and yielding into the main part of the page. Then set this to be the layout for all your admin controllers.

Mark Bush wrote:

Joel Slowik wrote:

What I would like to do and I am having a time getting it to work is to have a single admin page that will call all of these controller into one page ( I would imagine we would call this includes).

It sounds like what you want is to use one of the admin page's layouts and update it with, say, a sidebar containing the choices and yielding into the main part of the page. Then set this to be the layout for all your admin controllers.

Mark,

Yes that would work, and perhaps that might be what I should do.

I was more in particular thinking of this: http://www.activescaffold.com/tutorials/embedded as I use active scaffolds for my project.

Unfortunately I am receiving the error "undefined method `render' for PageController:Class".

Now, maybe the reason I am getting this error is a due to a lack of understanding. I am imagining what this is suppose to do is allow me to have all of my different scaffold controllers viewed under one page i.e. admin page.

Any ideas?

Joel Slowik wrote:

I was more in particular thinking of this: http://www.activescaffold.com/tutorials/embedded as I use active scaffolds for my project.

This allows you to create multiple views of a single controller action on the page.

Now, maybe the reason I am getting this error is a due to a lack of understanding. I am imagining what this is suppose to do is allow me to have all of my different scaffold controllers viewed under one page i.e. admin page.

Whatever scaffolding mechanism you use and whatever way you implement your controllers, the bottom line is that the URL requested gets put through the routing engine which causes a single action of a single controller to be called with a set of parameters. The result is that some text may or may not get created (rendered) and sent back for the user to see. The action may call another action to do the work and it may send back a redirect causing the browser to ask for another URL, but this is the gist of it.

The general scheme of the resultant text is that a view is rendered (with the above embedded example, multiple renderings can be performed) and then a layout is rendered (unless specifically prevented) with the view text placed where there is a call to "yield". Thus, the user sees a layout with part of that layout created by the rendering for a single controller action.

If you want to present the user with several choices of things to do, add them to the layout. If you want a single user request to do several things and return all the results, then you need a single controller action to coordinate getting all the data together and arranging for the view to be rendered.

The embedded scaffold example seems to be using "render" in the view in a similar manner in which you might normally call multiple partials in a view, but I haven't played with this so don't know the internals of what is going on there.