Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

when position is null all new items get inserted in position 1 #41

Closed
cdcdcd123 opened this Issue · 6 comments

5 participants

@cdcdcd123

I'm using 'remove_from_list' and a deleted_at attribute to remove items from list. The problem is that when creating a new record, if there are other records in the list with position of null, all new records get set to position 1. A workaround I've used is to set a default scope of :conditions => (:position ^ nil), but it seems to me at least, that the private method 'bottom_item' should have a default condition of position not nil.

@darkleaf

You can use other boolean column.
I think that position column should not have NULL value.
See http://en.wikipedia.org/wiki/Single_responsibility_principle.

@swanandp
Owner

True. If you look at it from a semantic perspective, a list cannot have items w/o position.

@cdcdcd123

I see your point. But why is there a remove_from_list method? What would be a use-case for this method?

@forrest

I've added some code to pull #72 which fixes this issue. Now items which have been removed from the list and respond false to :in_list? will not be fetched from :bottom_item. This is important because otherwise :add_to_list_bottom breaks.

@nathany

@swanandp Any chance of getting the fixes in #72 merged in?

@swanandp
Owner

@nathany Done!

@swanandp swanandp closed this
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.