Acts as list

hi, how would you insert a new item positioned after an existing item
of an acts_as_list ?

Create the Item

@item =[:item])

#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


class Item < ActiveRecord::Base

Create item

@item = Item.create(params[:item])

#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)

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs