Re: [Rails] Re: Find Company Name not ID
Apologies, fat-fingered premature send ...
On Sun, Jul 22, 2012 at 9:07 AM, Hassan Schroeder
<hassan.schroeder@gmail.com> 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 ------------------------ hassan.schroeder@gmail.com
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home