Apologies, fat-fingered premature send ...

On Sun, Jul 22, 2012 at 9:07 AM, Hassan Schroeder
<[email protected]> wrote:

> 3) Write a helper to return empty values for nil companies:
>     # untested example follows  :-)

      company_info_for(contact.company, 'company_name')
      # replaces contact.company.company_name in  view

     def company_info_for(company, attr)
         defaults = { :company_name => '' }
         return defaults[attr] if company.nil?
         company.send(attr)
     end

HTH!
-- 
Hassan Schroeder ------------------------ [email protected]
http://about.me/hassanschroeder
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 https://groups.google.com/groups/opt_out.


Reply via email to