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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I have to correct myself here. Although things work (dont work) in the order described the Category expected, got Category Error message still appears after a while and then continues to be there until a server restart. Now this is really a problem! A bit of googling revealed that is has to do with the plugins used. So these are the plugins used: acts_as_versioned acts_as_tree globalize Any idea ? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I am having trouble getting a single table inheritance to work. This is what I tried I made a base model called Product, made the migration with all columns for every type of product that I want to create. Also in my migration I made a column called type to differentiate between classes. Also, from what I read in AWD I put the :force -> true option after the table name. So now I ran the rake db migrate and it made the table. Then I made a class called DealProduct and I put it in the models folder as deal_product.rb. I also made it inherit the base class Product. So I had: DealProduct < Product end So then I made a controller called deal_product, and then I tried generating the scaffolding for the controller and the DealProduct controller, and it throws an error saying "Before updating scaffolding from new DB schema, try creating a table for your model (DealProduct)," but if I have it inherited from my base class Product, why is it throwing me this error, shouldn''t it know that it already has one? And am I even doing this right, is there anything that would make this not work? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
OOOOO, I got it, so I wasn''t generating the model first, I was just creating a new class. So what I did was generate the model, then in the model I put self.inheritance_column = ''type'' (don;t know if I needed this, but I saw it in the rails API), and then I ran rake db:migrate again to create the table. Now I generated the scaffolding for the controller and model and it worked !!!! :) But if anyone could tell me if I need that self.inheritance_column declaration in my child classes that would be great. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---