Say I have to Models, Project and Creator, related to each other such that @project.creator is valid. Creator has two fields, first_name and last_name, for the creator's name. Assuming that I want a quick way to display the creator's name as "last_name, first_name" inside the view, which is the best approach (efficiency, the Rails way, etc.) and why?
Here are the approached I've come up with... A) Create a method in the Creator class called commified_name and use @project.creator.commified_name in the view. This seems like a good option. It's DRY and fits the rest of the mold for @project.xyz in the view, but I think following MVC the model is not meant for formatting, right? def commified_name [self.last_name, self.first_name].join(', ') end B) Do the join inside the view. Probably the worst of the options since it allows for variations in how the name is displayed. C) Create a method in the Creator Helper called commified_name and use commified_name in the view. I believe this is the best answer since formatting of information that goes in the View belongs in a Helper, right? I just find that A feels more right to me. def commified_name [...@project.creator.last_name, @project.creator.first_name].join(', ') if @project end If C (or A) is the best answer, is this a good way to accomplish what I'm after. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---