hi, how would you insert a new item positioned after an existing item of an acts_as_list ? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
# Create the Item @item = Items.new(params[:item]) @item.save #Insert the Item at a given position. # I sassume the position is in params[:position], # and as we want to insert AFTER this position we add 1 @list.insert_at(params[:position]+1) On 31 Mai, 10:13, Jonathan Linowes <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, how would you insert a new item positioned after an existing item > of an acts_as_list ?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
class Item < ActiveRecord::Base acts_as_list end 1) # Create item @item = Item.create(params[:item]) 2) #params[:position] is assumed to contain the integer value of the list position after which to insert the item @item.insert_at(params[:position] + 1) On 31 Mai, 10:13, Jonathan Linowes <lino...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, how would you insert a new item positioned after an existing item > of an acts_as_list ?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---