What does the Magic Field Name position do? I was looking here: http://wiki.rubyonrails.com/rails/pages/MagicFieldNames And unfortunately that documentation is incomplete. Thanks. -- Posted via http://www.ruby-forum.com/.
Arch Stanton wrote:> What does the Magic Field Name position do? > > I was looking here: > http://wiki.rubyonrails.com/rails/pages/MagicFieldNames > > And unfortunately that documentation is incomplete. > > Thanks.When using acts_as_list, it keeps track of the position of the item on the list. joey__ -- Posted via http://www.ruby-forum.com/.
joey__ wrote:> Arch Stanton wrote: >> What does the Magic Field Name position do? >> >> I was looking here: >> http://wiki.rubyonrails.com/rails/pages/MagicFieldNames >> >> And unfortunately that documentation is incomplete. >> >> Thanks. > > When using acts_as_list, it keeps track of the position of the item on > the list. > > joey__Can the list be specific to a belongs_to relationship? -- Posted via http://www.ruby-forum.com/.
Arch Stanton wrote:> joey__ wrote: > >>Arch Stanton wrote: >> >>>What does the Magic Field Name position do? >>> >>>I was looking here: >>>http://wiki.rubyonrails.com/rails/pages/MagicFieldNames >>> >>>And unfortunately that documentation is incomplete. >>> >>>Thanks. >> >>When using acts_as_list, it keeps track of the position of the item on >>the list. >> >>joey__ > > > > Can the list be specific to a belongs_to relationship?Yes - use :order => :position in the belongs_to. -- Alex
Alex Young wrote:> Arch Stanton wrote: > >> joey__ wrote: >> >>> Arch Stanton wrote: >>> >>>> What does the Magic Field Name position do? >>>> >>>> I was looking here: >>>> http://wiki.rubyonrails.com/rails/pages/MagicFieldNames >>>> >>>> And unfortunately that documentation is incomplete. >>>> >>>> Thanks. >>> >>> >>> When using acts_as_list, it keeps track of the position of the item >>> on the list. >>> >>> joey__ >> >> >> >> >> Can the list be specific to a belongs_to relationship? > > Yes - use :order => :position in the belongs_to. >D''oh... Must not post before tea... class Parent < AR::Base has_many :children, :order => :position end class Child < AR::Base acts_as_list, :scope => :parent belongs_to :parent, :order => :position end -- Alex
Alex Young wrote:> Alex Young wrote: >>>>> >>> >>> >>> >>> Can the list be specific to a belongs_to relationship? >> >> Yes - use :order => :position in the belongs_to. >> > D''oh... Must not post before tea... > > class Parent < AR::Base > has_many :children, :order => :position > end > > class Child < AR::Base > acts_as_list, :scope => :parent > belongs_to :parent, :order => :position > endAhhh, that is cool. One more question: what is the difference between specifying the :order in belongs_to vs. has_many? I would think you only need specify :order in the has_many declaration. ?? -- Posted via http://www.ruby-forum.com/.
Arch Stanton wrote:> Alex Young wrote: > >>Alex Young wrote: >> >>>> >>>> >>>>Can the list be specific to a belongs_to relationship? >>> >>>Yes - use :order => :position in the belongs_to. >>> >> >>D''oh... Must not post before tea... >> >>class Parent < AR::Base >> has_many :children, :order => :position >>end >> >>class Child < AR::Base >> acts_as_list, :scope => :parent >> belongs_to :parent, :order => :position >>end > > > Ahhh, that is cool. > > One more question: what is the difference between specifying the :order > in belongs_to vs. has_many? I would think you only need specify :order > in the has_many declaration. ??Just looking at it, I can''t think where it would be useful, but it''s in the docs as a supported option, so I suppose it must do something :-) -- Alex