# STI wrongly triggered

**URL:** <https://www.ruby-forum.com/t/sti-wrongly-triggered/90460>\
**Category:** Rails\
**Created:** [March 29, 2007, 12:25am UTC](https://www.ruby-forum.com/t/sti-wrongly-triggered/90460 "2007-03-29T00:25:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![underbluewaters](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/5daacb/32.png) [@underbluewaters](https://www.ruby-forum.com/u/underbluewaters)\
**Post date:** [March 29, 2007, 12:25am UTC](https://www.ruby-forum.com/t/sti-wrongly-triggered/90460/1 "2007-03-29T00:25:36Z")

</div>

Hello all, I’m about to bust an o-ring over here! Please help!  
For some reason single-table inheritance is getting triggered when I  
don’t want it to. Here’s the code:

`
class Site < ActiveRecord::Base
def temporal_coverage
…
end
def project
…
end
end
class ExampleSite < Site
has_many :example_swath_observations
end
`

There really isn’t anything special going on here. I run a unit test  
involving ExampleSite.find(:all) and it is looking in “sites” for data!  
Same thing when I try from script/console.

I DONT have a type column in “sites” but I though, maybe its looking for  
another column as well. So I set this in environment.rb:

`
ActiveRecord::Base.inheritance_column = "***_you_activerecord"
`

Everything works if I do a “set\_table\_name” but that’s not really ideal.  
I’m not really sure where to go from here. Here’s my schema if that  
helps:  
``

# This file is autogenerated. Instead of editing this file, please use

the

# migrations feature of ActiveRecord to incrementally modify your

database, and

# then regenerate this schema definition.

ActiveRecord::Schema.define(:version =\> 6) do

create\_table “example\_sites”, :force =\> true do |t|  
t.column “site\_code”, :string  
t.column “label”, :string  
t.column “description”, :string  
t.column “latitude”, :float  
t.column “longitude”, :float  
end

create\_table “example\_swath\_observations”, :force =\> true do |t|  
t.column “date”, :date  
t.column “site\_id”, :integer  
t.column “taxon\_id”, :integer  
t.column “mean\_density”, :float  
t.column “standard\_error”, :float  
end

create\_table “example\_swath\_taxa”, :force =\> true do |t|  
t.column “genus”, :string  
t.column “species”, :string  
t.column “label”, :string  
t.column “code”, :string  
t.column “notes”, :string  
t.column “sampling\_warnings”, :string  
end

create\_table “sites”, :force =\> true do |t|  
t.column “bull”, :string  
end

end

---

<div class="post-metadata">

**Author:** ![underbluewaters](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/5daacb/32.png) [@underbluewaters](https://www.ruby-forum.com/u/underbluewaters)\
**Post date:** [March 29, 2007, 1:05am UTC](https://www.ruby-forum.com/t/sti-wrongly-triggered/90460/2 "2007-03-29T01:05:54Z")

</div>

Ok I added:  
self.abstract\_class = true  
to all the models I was subclassing and it worked. I was under the  
impression I didn’t need to do this though.

---

<div class="post-metadata">

**Author:** ![underbluewaters](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/5daacb/32.png) [@underbluewaters](https://www.ruby-forum.com/u/underbluewaters)\
**Post date:** [March 29, 2007, 1:33am UTC](https://www.ruby-forum.com/t/sti-wrongly-triggered/90460/3 "2007-03-29T01:33:33Z")

</div>

Yeah, this solution is less than ideal because then  
ExampleSite.kind\_of?(Site) == false
