Brian wrote:
> Apparently I assumed functionality that doesn't exist for this
> association.  Should I not be able to reference the target model as an
> attribute?
> 
> Here are my models:
> 
> class User < ActiveRecord::Base
>   has_one :membership
>   has_one :role, :through => :membership
> end
> 
> class Membership < ActiveRecord::Base
>   belongs_to :user
>   belongs_to :role
> end
> 
> class Role < ActiveRecord::Base
> end
> 
> 

Hi Brian,
I think even if it is has_one: through or has_many :through, you should 
define -
class User < ActiveRecord::Base
   has_many :membership
   has_one :role, :through => :membership
 end

when defining user and membership. Then try user.role
I have worked on has_many :through recently. My example -
http://manasivora.blogspot.com

Let me know if it helps -

Thanks,
Manasi
-- 
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 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