Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Update position when scope changes #19

Closed
chief opened this Issue · 4 comments

4 participants

@chief

In update, position remains the same when scope changes. I think that a solution should be to trigger add_to_list_bottom but I can't think of any global way, especially in complex scope cases. When it is just a field I use something like this

class TodoItem < ActiveRecord::Base
    belongs_to :todo_list
    acts_as_list :scope => :todo_list
    before_update :change_position

   def change_position
     add_to_list_bottom if todo_list_id_changed?
   end
 end

Is there a better way?

@swanandp
Owner

The use case here is when you move an item from one list to another. Thats a good use case and worth as feature. Let me think over this and get back to you.

@swanandp swanandp was assigned
@narath

I would also find this useful, since I am using this with acts_as_tree as well and this needs this functionality.
Also discussed (from 2009 though) at http://ramblings.gibberishcode.net/archives/one-activerecord-model-acting-as-a-list-and-tree/33

@swanandp
Owner

Ah, I forgot all about this.

@swanandp
Owner

There is no sure way of doing this, since you cannot predict what behavior is intended. We can however accept a block as callbacks or hooks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.