in a single table inheritance model, rails will automatically set the scope for acts_as_list to the ''type'' field as well as any other scope conditions we provide. Is there a way to disable this? i want to use STI but I want acts_as_list to disregard the class type when getting/setting positions. thanks alan
On 21/04/2005, at 5:51 AM, Alan Bullock wrote:> in a single table inheritance model, rails will automatically set the > scope for acts_as_list to the ''type'' field as well as any other scope > conditions we provide. > > Is there a way to disable this? i want to use STI but I want > acts_as_list to disregard the class type when getting/setting > positions.Set the scope manually. acts_as_list :scope => :some_sql_condition_string_or_association_name - tim lucas
On 4/21/05, Tim Lucas <t.lucas@toolmantim.com> wrote:> Set the scope manually. > > acts_as_list :scope => :some_sql_condition_string_or_association_nameHi Can you provide a SQL example ? I would like to get this working : class Player < AR::Base acts_as_list :scope => ''type = "#{self.class.to_s}"'' end class BasketballPlayer < Player end class FootballPlayer < Player end
> acts_as_list :scope => ''type = "#{self.class.to_s}"''This should be acts_as_list :scope => "type = ''#{self.class.name}''" cheers Gerret
On 2/3/06, Gerret Apelt <gerret.apelt@gmail.com> wrote:> > acts_as_list :scope => ''type = "#{self.class.to_s}"'' > > This should be > > acts_as_list :scope => "type = ''#{self.class.name}''"This is indeed the right class method. But this has no effect since quotes and double quotes must be swapped, like :counter_sql parameter in has_many (don''t know why...), else I get WHERE (type = ''Class'') according to development.log