# Has\_one with :source\_type

**URL:** <https://www.ruby-forum.com/t/has-one-with-source-type/147142>\
**Category:** Rails\
**Created:** [August 28, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/has-one-with-source-type/147142 "2008-08-28T19:19:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kadoudal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/f0a364/32.png) [@kadoudal](https://www.ruby-forum.com/u/kadoudal)\
**Post date:** [August 28, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/has-one-with-source-type/147142/1 "2008-08-28T19:19:29Z")

</div>

I am trying to extend the classic example

class Magazine \< ActiveRecord::Base  
has\_many :subscriptions

```
   has_many :rental_events ,
        :through => : subscriptions,
        :source => :redaer,
        :source_type => 'Business'

  has_many :closing_events ,
        :through => : subscriptions,
        :source => :reader,
        :source_type => 'Person'

```

end

class Subscription \< ActiveRecord::Base  
belongs\_to :magazine  
belongs\_to :reader, :polymorphic =\> true  
end

class Business \< ActiveRecord::Base  
has\_many : subscriptions, :as =\> :reader  
has\_one :magazine, :through =\> :subcription \<---- that’s what I  
want , only 1 magazine…  
end

class Person \< ActiveRecord::Base  
has\_many : subscriptions, :as =\> :reader  
has\_one :magazine, :through =\> :subcription \<---- that’s what I  
want , only 1 magazine…  
end

I can easily get Person.first.subscriptions, but I cannot get  
Person.first.magazine or Business.first.magazine

what’s wrong ? , thanks for your lights …

erwin
