hi,
The “how do I include this universally?” went down pretty easily once I
figured it out. Essentially, I created the controllers to access the data from the requisite models, then coded the view templates, then moved the controllers so that they belonged to > ActionController::Base
rather than > ApplicationController. Then I included the two controllers in my template by using render_controller => ‘projects’, action => ‘thumbs’. This wasn’t the most elegant solution because my
‘projects’ controller originally was used for two actions (thumbs/list, and show/display), and the two needed to be seperate (because show needed to be a class of AppController, while thumbs needed to belong to
ActionController). Then the features controller is stuck I think in the main app controller. So it’s not the most elegant way of approaching it, but I figure as I learn things I’ll go back & clean everything up
so it’s a little more fluid. I’m getting the impression that a lot of people learn the Rails this way, since the documentation is so all-over-the-place and varied.
I’m lost… Although you can extend classes directly from ActionController::Base i guess you shouldn’t follow that approach, instead of:
ActionController::Base ConcreteController01 and
ApplicationController
CustomController02
you could do
+ApplicationController ±— ConcreteController01 ±— SarahsBaseController ±-- ConcreteController01
This way you are shielded against some Rails Core changes at ApplicationController’s level. For instance rails 1.2 RC introduces the following at this level ‘session :session_key => ‘_APP_NAME_session_id’’
Regarding layouts or global layouts whatever you put in them don’t necessarily have to be “static” you are not limited to decorate whatever comes <%= yield %>. its possible to replace/include other parts of these layouts.
Check the api for:
- capture
- content_for
- render (with runtime parameters)
I’m working on something that have some views with googlemaps stuff, in this views there are some javascript files that must be included. I reference javascript files from each concrete view but, i want all javascript references to be on top of the page inside which are in a single site wide layout. By using content_for i’ve been able to dinamically place what, where, when i need without resorting to duplication of code.
Also as my knowledge of rails is increasing i’m using partials everywhere, started using them to render lists, or specific blocks of a page, but now i’m all for partials of partials of partials… to the point where its possible to interchange or reusing them between diferent views. More or less like a lego metaphor, a lego block is a partial, a piece its a composition of blocks/partials and so on until you work your way out to the result page.
have fun with rails
Jorge