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?