olivier Hericord
2006-May-21 21:36 UTC
[Rails] acts_as_list scope and polymorphic association.
this is my model: class Person < ActiveRecord::Base has_many :phones, :as => :callable, :order => :position end class Phone < ActiveRecord::Base belongs_to :callable, :polymorphic => true acts_as_list :scope => :callable_id end how can i add the callable_type to the scope. how can i say the scope is the {:callable_id,:callable_type} couple? is it even possible? thanks
olivier Hericord
2006-May-21 21:45 UTC
[Rails] Re: acts_as_list scope and polymorphic association.
in fact i should have something like :scope => ''callable_id = #{parent_object_id} and callable_type #{parent_object_type}'' how can i write in ruby parent_object_id and parent_object_type? this.parent.type ? this.parent.id? :) can''t get something that work help On 5/21/06, olivier Hericord <olivier.hericord.lists@gmail.com> wrote:> this is my model: > > class Person < ActiveRecord::Base > has_many :phones, :as => :callable, :order => :position > end > > class Phone < ActiveRecord::Base > belongs_to :callable, :polymorphic => true > acts_as_list :scope => :callable_id > end > > how can i add the callable_type to the scope. > how can i say the scope is the {:callable_id,:callable_type} couple? > > is it even possible? > > > thanks >
olivier Hericord
2006-May-21 21:50 UTC
[Rails] Re: Re: acts_as_list scope and polymorphic association.
finally solved it on my own just after starting this thread :) ''callable_id=#{callable_id} and callable_type=#{quote callable_type}'' On 5/21/06, olivier Hericord <olivier.hericord.lists@gmail.com> wrote:> in fact i should have something like > > :scope => ''callable_id = #{parent_object_id} and callable_type > #{parent_object_type}'' > > > how can i write in ruby parent_object_id and parent_object_type? > > this.parent.type ? this.parent.id? :) > > > can''t get something that work > > help > > > On 5/21/06, olivier Hericord <olivier.hericord.lists@gmail.com> wrote: > > this is my model: > > > > class Person < ActiveRecord::Base > > has_many :phones, :as => :callable, :order => :position > > end > > > > class Phone < ActiveRecord::Base > > belongs_to :callable, :polymorphic => true > > acts_as_list :scope => :callable_id > > end > > > > how can i add the callable_type to the scope. > > how can i say the scope is the {:callable_id,:callable_type} couple? > > > > is it even possible? > > > > > > thanks > > >
olivier Hericord
2006-May-21 21:54 UTC
[Rails] Re: Re: Re: acts_as_list scope and polymorphic association.
on my own with Rails Weenie help :) On 5/21/06, olivier Hericord <olivier.hericord.lists@gmail.com> wrote:> finally solved it on my own just after starting this thread :) > > ''callable_id=#{callable_id} and callable_type=#{quote callable_type}'' > > On 5/21/06, olivier Hericord <olivier.hericord.lists@gmail.com> wrote: > > in fact i should have something like > > > > :scope => ''callable_id = #{parent_object_id} and callable_type > > #{parent_object_type}'' > > > > > > how can i write in ruby parent_object_id and parent_object_type? > > > > this.parent.type ? this.parent.id? :) > > > > > > can''t get something that work > > > > help > > > > > > On 5/21/06, olivier Hericord <olivier.hericord.lists@gmail.com> wrote: > > > this is my model: > > > > > > class Person < ActiveRecord::Base > > > has_many :phones, :as => :callable, :order => :position > > > end > > > > > > class Phone < ActiveRecord::Base > > > belongs_to :callable, :polymorphic => true > > > acts_as_list :scope => :callable_id > > > end > > > > > > how can i add the callable_type to the scope. > > > how can i say the scope is the {:callable_id,:callable_type} couple? > > > > > > is it even possible? > > > > > > > > > thanks > > > > > >