Closed goalaleo closed 6 years ago
Hi @goalaleo, you can actually just pass the position you want into the .new
method:
new_dog = Dog.new(person: person, name: "Second Dog", position: 1)
Acts As List will shuffle things around so that your new object has that position and the others don't. insert_at
is for existing records either in this scope or any other scope.
I hope that helps. I'll close this for now but let me know if you think I've missed the point.
@brendon ok, thanks 👍 ! I still feel like the naming of insert_at
is a bit misleading, as it does work on new instances, does a literal insert DB operation, but doesn't actually insert the record to the given position :/ Either way, great gem!
@goalaleo, yes you're right. It should probably be named reposition_at
or something like that though that would break the api and I think this method has been around since the beginning. @swanandp, did you have any thoughts on this one?
I would expect an ArgumentError or something for new records rather than silently failing.
Thanks @DanielHeath :) Would you be keen to put together a small PR for that? I'd be happy to merge that for you.
Makes sense to me, will do.
Upon closer inspection, there's clearly code intended to insert new records at the right position.
I've fixed it so this case now works.
Request
Currently the position of a new record uses the
add_new_at
value. Is it possible to make new records respect the parameter given toinsert_at
.Example: