On Sat, Feb 28, 2009 at 1:32 AM, ericindc <ericmilf...@gmail.com> wrote:
>
> Ok, I follow having all models respond to "title", but why would
> implementing the model's "to_s" method be a better approach?  Is it
> just for consistency, always expecting to_s to return what the partial
> should display?  How is that any different that expecting all models
> to answer to title?
>

First it's for the sake of consistency, but it's also 'cos the to_s
method is defined to return a "string representation of the object",
so if you already have a method that does what you want, why create
another one or why care about creating another method that "returns a
string representation of the object"?

This way you don't need to add extra virtual methods at your models,
you just expect them to have a good to_s implementation.

> Thanks.  This has been really helpful.  I used your example to create
> the following.  Thoughts?
>
> http://pastie.org/402843

It's good, but that's how I'd do it -> http://pastie.org/403009

The more conventions you have, the easier it is to keep things
consistent in your pages.

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to