Hi all I have a model Product1 and Product2 which both have Product as parent class. I use single table inheritance to share their similar DB fields. Now I wanted to add acts_as_list for them, and wanted to use :scope => :type so the position numbers are not shared between Product1 and Product2 but every Class has its own order. Sadly when adding a new Product1 or Product2 I get the following error: NameError in UnikateController#manage undefined local variable or method `type_id'' for #<Product1:0x25a5270> Why does Rails append an "_id" suffix to type? Is it not possible to use "type" only? Thanks. Josh -- 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 -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2006-Dec-16 11:23 UTC
Re: STI and acts_as_list: scope => type does not work?
Well got it myself already. Rails API: scope - restricts what is to be considered a list. Given a symbol, it’ll attach "_id" (if that hasn’t been already) and use that as the foreign key restriction. So I''m using a string now instead of a symbol, and it works. Quite strange behavior though, is this consistently used throughout Rails? "Symbols can be modified by Rails, strings are taken as-is"? -- 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 -~----------~----~----~----~------~----~------~--~---