Here's my situation: I have a pair of controllers with associated
models (called Services and Testimonials) that are quite similar.
Because their CRUD behavior is executed via AJAX, the "templates" for
the actions are all short .rjs files. Now, because of the similarity
of the models, most of the templates are exactly the same, with only
the object names changed. That is, where one looks like this:
Obviously there's no reason these should be separate. My question is,
what's the best way to set these up as shared templates? Both of the
controllers inherit from a third controller (Brochure) because of
shared authentication behavior. But the only way I can think of to
share templates is something like this:
Put template files in /views/brochure.
At the end of each action, explicitly render the template. i.e.
Actually, I got that part pretty well solved by just changing
everything to "widget."
The part I'm wondering is if there's some way to re-route most of a
controller to a different set of views than the standard default.
Right now every action ends with "render :template => 'widget/
action_name'" but I'm curious if there's a better way.
Sure. No, there really isn't. It's a convenience thing. Not having to
specify the template is a blessing in most cases. Thing is, you could
probably do simething interesting with before / after filters.