# :through and STI

**URL:** <https://www.ruby-forum.com/t/through-and-sti/56070>\
**Category:** Rails\
**Created:** [March 27, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/through-and-sti/56070 "2006-03-27T22:07:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeroen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Post date:** [March 27, 2006, 10:07pm UTC](https://www.ruby-forum.com/t/through-and-sti/56070/1 "2006-03-27T22:07:10Z")

</div>

Hi,

I’m trying to use :through and STI using the trunk version of Rails, but  
I get the following error see bottom of this msg[1]

here are my classes.

class Player \< ActiveRecord::Base  
end

class Ladder \< ActiveRecord::Base  
has\_many :subscriptions  
has\_many :players, :through =\> :subscriptions  
end

class SingleLadder \< Ladder  
end

class Subscription \< ActiveRecord::Base  
belongs\_to :players  
belongs\_to :ladders  
end

Any ideas??

Jeroen

[1]

> > Ladder.find(:first).players  
> > NameError:  
> > ./script/…/config/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active\_support/dependencies.rb:89:in  
> > `const_missing': uninitialized constant Players from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1197:in`instance\_eval’  
> > from  
> > ./script/…/config/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active\_support/dependencies.rb:120:in  
> > `const_missing' from ./script/../config/../config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:122:in`send’  
> > from  
> > ./script/…/config/…/config/…/vendor/rails/activerecord/lib/…/…/activesupport/lib/active\_support/dependencies.rb:122:in  
> > `const_missing' from (eval):1:in`instance\_eval’  
> > from  
> > ./script/…/config/…/config/…/vendor/rails/activerecord/lib/active\_record/base.rb:1197:in  
> > `instance_eval' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/base.rb:1197:in`compute\_type’  
> > from  
> > ./script/…/config/…/config/…/vendor/rails/activerecord/lib/active\_record/reflection.rb:112:in  
> > `send' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/reflection.rb:112:in`klass’  
> > from  
> > ./script/…/config/…/config/…/vendor/rails/activerecord/lib/active\_record/associations/has\_many\_through\_association.rb:54:in  
> > `find_target' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:116:in`load\_target’  
> > from  
> > ./script/…/config/…/config/…/vendor/rails/activerecord/lib/active\_record/associations/association\_proxy.rb:109:in  
> > `method_missing' from ./script/../config/../config/../vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb:47:in`method\_missing’  
> > from  
> > /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:296:in  
> > `output_value' from /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:149:in`eval\_input’  
> > from  
> > /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:145:in  
> > `signal_status' from /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:145:in`eval\_input’  
> > from  
> > /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:144:in  
> > `each_top_level_statement' from /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:144:in`eval\_input’  
> > from  
> > /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:70:in  
> > `start' from /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:69:in`catch’  
> > from  
> > /Applications/Locomotive/Bundles/rails-1.0.0-max.bundle/Contents/Resources/ports/lib/ruby/1.8/irb.rb:69:in  
> > `start’  
> > f

---

<div class="post-metadata">

**Author:** ![jeroen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Post date:** [March 27, 2006, 10:16pm UTC](https://www.ruby-forum.com/t/through-and-sti/56070/2 "2006-03-27T22:16:41Z")

</div>

Jeroen H. wrote:

> class Subscription \< ActiveRecord::Base  
> belongs\_to :players  
> belongs\_to :ladders  
> end

> `const\_missing’: uninitialized constant Players

Your belongs\_to associations should be singular:

class Subscription \< ActiveRecord::Base  
belongs\_to :player  
belongs\_to :ladder  
end

–josh  
[http://blog.hasmanythrough.com](http://blog.hasmanythrough.com)

---

<div class="post-metadata">

**Author:** ![jeroen](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@jeroen](https://www.ruby-forum.com/u/jeroen)\
**Post date:** [March 28, 2006, 8:08am UTC](https://www.ruby-forum.com/t/through-and-sti/56070/3 "2006-03-28T08:08:49Z")

</div>

Josh S. wrote:

> class Subscription \< ActiveRecord::Base  
> belongs\_to :player  
> belongs\_to :ladder  
> end

Whoops! Well spotted - looking at your URL it seems you’re the man to  
ask 😉

Thanks,

Jeroen
