On 24 February 2011 18:12, Peter D Bethke <[email protected]> wrote:
> Thanks Fred!
>
> Does this look right? I'm still getting an error for some reason:

Always post the error... just saying "I've got one" doesn't help
people point out where you might be having problems (although in this
case, it's ruby syntax... check the API for the ".collect" method :-)

  def get_company_branches
    my_branches =  self.company.branches # you don't really need these
intermediate variables... just use self.branches.collect....
    my_list = my_branches.collect { |x| x.branch_name }
    return my_list.join(", ") # "collect" returns an array, so we can
join the array into a string, or maybe use the "to_sentence" extension
to prettify it
  end


...my previous method just does the same, a little more compact.

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

Reply via email to