Now I'm especially stumped. I rewrote this as a has_many :through:
class User < ActiveRecord::Base
has_many :memberships
has_many :roles, :through => :memberships
end
class Membership < ActiveRecord::Base
belongs_to :user
belongs_to :role
end
class Role < ActiveRecord::Base
has_many :memberships
end
But when I create a user, membership, and role, I still cannot access
role through user:
user = User.new
user.save!
membership = user.memberships.create
role = membership.create_role
When I look at the value of user.roles(true) I get an empty array.
Obviously I'm doing something very wrong.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---