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

insert_at creates gaps #108

Closed
volontarian opened this issue Feb 21, 2014 · 1 comment
Closed

insert_at creates gaps #108

volontarian opened this issue Feb 21, 2014 · 1 comment

Comments

@volontarian
Copy link

I am using version 0.3.0 and want this feature.

Given

ranking = Ranking.create(name: 'Dummy')
ranking.items.create(ranking_id: ranking.id, name: 'Thing 1')
ranking.items.create(ranking_id: ranking.id, name: 'Thing 2')
ranking.items.create(ranking_id: ranking.id, name: 'Thing 3')

When

item = ranking.items.new(name: 'Thing 2.0')
item.insert_at(2)

Then

ranking.items.order('position ASC').all.map{|i| [i.position, i.thing.name]}.should == [
  [1, "Thing 1"], [2, "Thing 2.0"], [3, "Thing 2"], [4, "Thing 3"]
]

But I got

ranking.items.order('position ASC').all.map{|i| [i.position, i.thing.name]}.should == [
  [1, "Thing 1"], [2, "Thing 2.0"], [4, "Thing 2"], [5, "Thing 3"]
]
@swanandp
Copy link
Contributor

@gawlista Fixed, do update to 0.4.0

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