我通过将以下行放入 Gemfile 和“捆绑安装”进行安装:
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
这个插件是否不适用于 rails 3 或者我错过了一步?
这是我正在使用的代码:
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
这是控制台:
wq = WorkQueue.new
technician = Technician.last
wq.technicians << technician