Ruby on rails 轨道作为列表位置自动递增

Ruby on rails 轨道作为列表位置自动递增,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我使用的是acts_as_list gem,但在创建新对象时,位置应自动增加大小和顺序位置ASC LessonPage模型 class LessonPage < ActiveRecord::Base acts_as_list :scope => 'lesson_id = #{lesson_id}' default_scope order('position ASC') end 插入-第一个 INSERT INTO "lesson_pages" ("created_a

我使用的是acts_as_list gem,但在创建新对象时,位置应自动增加大小和顺序位置ASC

LessonPage模型

class LessonPage < ActiveRecord::Base
    acts_as_list :scope => 'lesson_id = #{lesson_id}'
    default_scope order('position ASC')
end
插入-第一个

INSERT INTO "lesson_pages" ("created_at", "lesson_id", "position", "updated_at") VALUES (?, ?, ?, ?)  [["created_at", Sun, 16 Oct 2011 11:55:27 CEST +02:00], ["lesson_id", 2], ["position", 1], ["updated_at", Sun, 16 Oct 2011 11:55:27 CEST +02:00]]
第二

INSERT INTO "lesson_pages" ("created_at", "lesson_id", "position", "updated_at") VALUES (?, ?, ?, ?)  [["created_at", Sun, 16 Oct 2011 11:57:15 CEST +02:00], ["lesson_id", 2], ["position", 2], ["updated_at", Sun, 16 Oct 2011 11:57:15 CEST +02:00]]
第三

这里它失败了,因为位置应该是3而不是2。我该如何解决这个问题?
谢谢

我想这已经修复了,但修复后没有发布。我认为您应该使用github的代码

使用以下命令:

gem 'acts_as_list', :git => 'https://github.com/swanandp/acts_as_list.git'

我认为这是固定的,但没有释放后,这个修复。我认为您应该使用github的代码

使用以下命令:

gem 'acts_as_list', :git => 'https://github.com/swanandp/acts_as_list.git'

您使用的是什么版本的acts_as_列表?我想这是由commit()更新修复的:哦,我明白了。此提交后没有发布。我认为你应该使用github的代码。你是一个天使!它的工作原理是正确的:git repo!令人惊叹的!请接受下面的答案。您使用的是什么版本的acts_as_列表?我想这是由commit()更新修复的:哦,我明白了。此提交后没有发布。我认为你应该使用github的代码。你是一个天使!它的工作原理是正确的:git repo!令人惊叹的!请接受下面的答案。此gem使用旧ruby 1.8.7不支持的新哈希样式。所以我不得不使用这个提交的代码(在你的问题评论中列出)作为猴子补丁。非常有帮助。谢谢。这个gem使用了旧ruby 1.8.7不支持的新哈希样式。所以我不得不使用这个提交的代码(在你的问题评论中列出)作为猴子补丁。非常有帮助。非常感谢。
gem 'acts_as_list', :git => 'https://github.com/swanandp/acts_as_list.git'