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

Order is reversed when adding multiple rows at once #34

Closed
d13r opened this issue Apr 7, 2012 · 0 comments
Closed

Order is reversed when adding multiple rows at once #34

d13r opened this issue Apr 7, 2012 · 0 comments

Comments

@d13r
Copy link

d13r commented Apr 7, 2012

Using code similar to this:

list = List.new title: "List 1"
list.items.new text: "Item 1"
list.items.new text: "Item 2"
list.items.new text: "Item 3"
list.save!

The items get inserted into the list in reverse order.

This is because before_validation :add_to_list_bottom is run for all rows before any row is saved, so they all get position set to 1. Then each item that is saved causes the ones before it to be pushed further down the list.

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

2 participants