Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
cdcdcd123 opened this issue Jul 13, 2012 · 6 comments
Closed

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

cdcdcd123 opened this issue Jul 13, 2012 · 6 comments

Comments

@cdcdcd123
Copy link

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
Copy link

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
Copy link
Contributor

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

@cdcdcd123
Copy link
Author

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

@forrest
Copy link
Contributor

forrest commented Feb 26, 2013

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
Copy link

nathany commented Mar 6, 2013

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

@swanandp
Copy link
Contributor

swanandp commented Mar 6, 2013

@nathany Done!

@swanandp swanandp closed this as completed Mar 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants