Forum: Ruby on Rails single table inheritance problem

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
30fc4868298db693aa031d4ef6dea0b2?d=identicon&s=25 migo (Guest)
on 2007-07-22 14:39
(Received via mailing list)

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

- two tables one called "wikis" on called "categories" with a hbtm
- 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
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

I get the VERY unhelpful error messages telling me

in WikisController#add_category
Category expected, got Category

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

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.

This topic is locked and can not be replied to.