On Thu, Apr 15, 2010 at 11:36 AM, dan <[email protected]> wrote: > if thing.foo is a date, price, url or something else that requires > formatting, it requires more than =thing.foo > and since you cant format nil, a test needs to be performed before > trying to format said data > my views are getting littered with these tests and formats, sometimes > there nested:
Some possible approaches: 1) make the default in the database some value other than null. 2) <%= @thing.foo.format rescue nil %> 3) <%= @thing.foo.nil? ? " N/A " : @thing.foo.format %> I'm sure someone will suggest others, but HTH :-) -- Hassan Schroeder ------------------------ [email protected] twitter: @hassan -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

