I recently posted this on the ruby group instead of here
but here is what I am attempting to do.
I am building a site, and I wish to populate the navigation dynamically
from a MySQL db table, and the page content from a different table.
The idea being I can have the navigation on every page, and use
different controllers to select different content depending on what is
needed.
example:
The Event page content comes from a page table where id = someValue
but I also need some events (days out etc, presentations), they come
from the events table.
I am confused how to put all the pieces together in one page.
add a before_filter to your app controller that calls a method to
build the data for your sidebar
before_filter :build_sidebar
....
private
def build_sidebar
if controller_name = "page"
do something
elseif controller_name = "someothercontroller"
do somethingelse
end
end
and then render your navigation partial in your layout
(application.rhtml):
<%= reder :partial => :navigation %>
and in your _navigation.rhtml you build your naviation based on the
variables/data populated in the beforefilter.
2') about the "different controllers in one page"
i think you are thinking the wrong way. you have a controller for each
Model, and want to put those controllers together. You dont need 1
controller for each model.
Instead, you should have a controller for each section/logic of your
site, and in each of these controllers you access various Models to
create your views etc.