Pardee, Roy
2008-Jul-17 15:18 UTC
strategy for partials needed--DRYing up list-generating code
Hey All, I''m fighting the urge to just copy/paste view template code & would like advice on a better strategy. Consider this model: Project name start_date status * funder * funding_mechanism * <etc.> Where the *''d attributes are references to other models. I want to generate tables listing projects in all of these views: 1) projects/index 2) statuses/4/show 3) funders/2/show 4) funding_mechanisms/4/show For #1, I want to show all of the columns of the projects, but for the others, I want to leave out whichever column is redundant given the thing I''m "show"ing. So for instance, say /statuses/4 is the ''active'' status. I want to caption my table "Projects that are currently Active", and then show all of the project columns except for status. Likewise, for funders/2 I want a caption "Projects funded by NCI", and to show all columns except for funder. Optimally, this would all be in a single partial that would morph depending on the context from which I called it. Is there a way to write that partial w/out making it a hell-broth of if/then statements? Or is that just a butt-kicking I''ve got to take? Thanks! -Roy Roy Pardee Research Analyst/Programmer Group Health Center For Health Studies (Cancer Research Network) (206) 287-2078 Google Talk: rpardee --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---