Model#find returns wrong class

Hi,

I've one specific database view which troubles me. I set up a model mytestmodel.rb:

class Mytestmodel < ActiveRecord::Base   set_table_name "shop_view1" end

./script/console output (development environment)

Mytestmodel.find(:first)

=> #<Product id: 260, ...>

development.log output:   Mytestmodel Load (0.030650) SELECT * FROM "shop_view1" LIMIT 1

Why do I get an object of Product class back here? I guess this is somewhere cached. When I change "set_table_name" to another view, I get a Mytestmodel back, like expected. When I change it back, I always get a Product class.

I tried this with rails 2.0.2 and 2.1.0 on ruby 1.8.6 using a postgresql 8.3 database. All caching options in environments/development.rb are turned off.

I restarted everything on my local machine, deleted all files in ./tmp/ , stopped memcached, but this behaviour still exists.

Any clue where to search for the problem here?

Joachim Glauche wrote:

Mytestmodel.find(:first)

=> #<Product id: 260, ...>

Gotcha!

ActiveRecord uses the table field "type" when determine the model name. It doesn't seem to matter if you have actually a inherited model of that type or not. It would be a nice feature if you get a warning here.

Well a simple self.inheritance_column = "" to the model does the trick