I need some code refactored as it is very ugly.

   memberships = customer.companies.collect(&:name).sort().join(',')

  for membership in customer.memberships
          membership.membership_roles.each do |membership_role|
            cust_roles << membership_role.role.name + ", "
          end
   end

Here's the active record relation:

customer has many memberships
membership_role belongs to membership and role  (link table)

Is there a more compact, cleaner way to write this?

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/69a582ebfb52c924730e55615678d359%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to