Re: common list for controllers

Florian Groß
2005-05-10T23:05:05Z

Steven Knight wrote:

> For the project I''m working on I have a large number of tables (
12 )
> which I have created controllers for.  The problem is that after
> creating these controllers I have 12 list.rhtml files.
> [...]
> I would rather not have to keep changing all 12 of the list.rhtml files
> when I find a bug in one, or want to add a new feature in another, etc.
>
> What is the best way to go about doing this?  Has anyone done something
> like this is the past?

One way would be to use components. Maintain one central list.rhtml and
then do  render_component(:controller => "maintain_controller",
:action
   => "list")  in the other views.

You should also be able to use partials.

I would chose partials when you have to pass Arrays or other non-trivial
data (like an id or single string) to the central part and components in
the other cases. I think components will be easier to cache in the future.