single table inheritance problem

Hallo,

I am having a very strange Problem with STI in my application.

setup: - two tables one called "wikis" on called "categories" with a hbtm relationship. - the wikis table is the sti one with a model PageWiki being extended from Wiki (and the correspondig type column)

Following happens: - server restart - get :wikis, :show_pages - in show_pages the first line says PageWiki.find(:all) ! Now I get the following error

LoadError in WikisController#list_pages app/models/page_wiki.rb to define PageWiki // (it is of course defined there )

If i call the page again everythings works as it should be and the the error message never appears again until the server restarts BUT ! When I now try to add categories to my wikis with

@wiki = Wiki.find(params[:wiki]) @category = Category.find(params[:id]) @wiki.categories << @category unless @wiki.categories.index(@category)

I get the VERY unhelpful error messages telling me

ActiveRecord::AssociationTypeMismatch in WikisController#add_category Category expected, got Category

This error does not appear if do not call the list_pages method before.

If I change the line PageWiki.find(:all) to Wiki.find(:all, :conditions =>"type='PageWiki'") it all works.

Does anybody have any ideas what happens here? Thanks a lot for any help.

migo