Ant*_*y H 5 acts-as-list ruby-on-rails-3
我通过在Gemfile和'bundle install'中放入以下行来安装:
gem 'acts_as_list', '>= 0.1.0'
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用它时,结果并不像预期的那样:
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
Run Code Online (Sandbox Code Playgroud)
这个插件是不能用于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
Run Code Online (Sandbox Code Playgroud)
这是控制台:
wq = WorkQueue.new
technician = Technician.last
wq.technicians << technician
Run Code Online (Sandbox Code Playgroud)
不要使用"act-as-list"gem,因为这个gem不会长时间更新.
试试这个:
rails plugin install git://github.com/swanandp/acts_as_list.git
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6191 次 |
| 最近记录: |