I am almost embarrased to ask this and I am sure it has been answered
previously but the search feature is down on ruby-forum so I am not
finding the answer.
I have several controllers (leads, orders, activities, etc…). I have
a ton of repeated html in each of the views for these controllers. For
example, my list view has the same table/tr/td and for…in type of code
and it just utilizes different objects based on the controller (@lead,
@order, @activity, etc…).
I have created partials for the header/footer and also for individual
sections of the page (search, list, etc…). However, I would like to
further reduce the duplication.
Does anyone know the best way to do this? Ideally, I would have a
partial (or something similar) that could take in an object from any
controller, a list of columns that I want added from that object, table
headings, etc… and produce the output - independent of the
To further explain:
Assume I have a Lead. Lead has first_name, last_name, assigned_to,
created_at, phone_number_home, etc…
I want first_name, last_name and created_at to show up in the table as
rows and I want “First Name”, Last Name" and “Date Created” as the table
headings. Even if my object has 50 fields, I only want a select few of
them to show up in the list and want to be able to specify the ones to
Then, I have an activity. For Activity, I have activity_type,
start_date, created_at, end_date, assigned_to, etc… I want the
headings to be “Activity Type”, “Date Created”, and “Assigned To”.
What is the best approach to take here? If I make a change to the table
then I want it to be universal - so only one change instead of many as I
have now. Make sense?
If there are examples of this already then please point me in the right
direction. Otherwise, suggestions are greatly appreciated.
mmodica at cox dot net