Ruby on rails 3 有人让acts_as_列表在rails 3上工作吗?

Ruby on rails 3 有人让acts_as_列表在rails 3上工作吗?,ruby-on-rails-3,acts-as-list,Ruby On Rails 3,Acts As List,我是通过在Gemfile和“bundle install”中放入以下行来安装的: gem 'acts_as_list', '>= 0.1.0' 但是,当我尝试使用它时,结果并不像预期的那样: technician.move_to_top #works => position = 1 technician.move_to_bottom #does not work properly; also makes position = 1 technician.move_high

我是通过在Gemfile和“bundle install”中放入以下行来安装的:

gem 'acts_as_list', '>= 0.1.0'  
但是,当我尝试使用它时,结果并不像预期的那样:

technician.move_to_top #works => position = 1  
technician.move_to_bottom #does not work properly; also makes position = 1  
technician.move_higher #does not work; returns nil  
technician.move_lower #does not work; also returns nil  
这个插件是不能与Rails3一起工作,还是我遗漏了一个步骤

以下是我正在使用的代码:

class WorkQueue < ActiveRecord::Base  
  has_many :technicians, :order => "position"  
end  

class Technician < ActiveRecord::Base  
  belongs_to :work_queue  
  acts_as_list :scope => "work_queue_id" #I also tried using work_queue  
end  
类工作队列“职位”
结束
类技师“work_queue_id”#我也尝试过使用work_queue
结束
这是控制台:

wq = WorkQueue.new  
technician = Technician.last
wq.technicians << technician  
wq=WorkQueue.new
技师=技师

wq.technologies看起来它应该可以工作:

不要使用“作为列表”gem,因为这个gem很长时间都不会更新

试试这个:

rails plugin install git://github.com/swanandp/acts_as_list.git

acts_as_list 0.2.0在Ruby 1.9.3上的Rails 3.2.11中为我工作。然而,我已经读过这本书和其他我能找到的书,但是没有一本能让它正常工作。您正在使用它吗?为什么要指定版本。我认为您需要rails3的最新版本,即0.1.2。当前安装的版本是0.1.2。这就是我建立清单的方式吗?wq.技术人员发布您的添加代码-我觉得这似乎不对,但我需要在上下文中查看它。我编辑了问题以包含代码(上面的代码更可读)…感谢您花时间帮助我…可能是位置不是连续的数字?使用gem acts_作为_列表时面临相同的问题。你找到解决方法了吗。我使用的是Rails 3.2.2,您可以使用gem
acts\u as\u列表
test "acts_as_list methods" do
  list = ToDoList.create(description: 'To Do List 1')

  task1 = list.tasks.create(description: 'Task 1')
  task2 = list.tasks.create(description: 'Task 2')
  task3 = list.tasks.create(description: 'Task 3')

  assert_equal 3, list.tasks.count
  assert_equal task1.id, list.tasks.order(:position).first.id
  assert_equal task3.id, list.tasks.order(:position).last.id

  # Move the 1st item to the bottom. The 2nd item should move into 1st
  list.tasks.first.move_to_bottom

  assert_equal 3, list.tasks.count
  assert_equal task2.id, list.tasks.order(:position).first.id
  assert_equal task1.id, list.tasks.order(:position).last.id
end