I have a many to many association such as
class User < ActiveRecord::Base
has_many :working_groups
has_many :groups, :through => :working_groups
class Group < ActiveRecord::Base
has_many :working_groups
has_many :users, :through => :working_groups
class WorkingGroup < ActiveRecord::Base
belongs_to :user
belongs_to :group
And the Working_Groups association has some additional info about each relationship (such as order and type of membership):
create_table "working_groups", :force => true do |t|
t.integer "group_id"
t.integer "user_id"
t.integer "position"
t.string "role"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
In the user view, I'm trying to display a list of all the groups the user belong toand their type of membership (which is stored in the join table). The only way I found to get this done is something like this, that looks extremely ugly and not the most efficient thing ever...
Name RoleIs there a better way to do this? There must be a better way...