Is there someone who got act_as_list for working with rails 3?

I installed by putting the following line in the Gemfile and 'bundle install':

gem 'acts_as_list', '>= 0.1.0'  

However, when I try to use it, the results are not as expected:

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  

Does this plugin just not work with rails 3 or did I skip a step?

here is the code i use:

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  

this is the console:

wq = WorkQueue.new  
technician = Technician.last
wq.technicians << technician  
+5
source share
3 answers

Do not use the "act-as-list" symbol because this stone has not been updated for a long time.

Try the following:

rails plugin install git://github.com/swanandp/acts_as_list.git
+9
source

act_as_list 0.2.0 Rails 3.2.11 Ruby 1.9.3. < . list.tasks.create().

:

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

, to_do_list, act_as_list , to_do_list_id == nil. _ < , act_as_list .

test.log, SQL, act_as_list, , .

, , work_queue, '< <'. act_as_list TechnicianWorkQueue, act_as_list Technician WorkQueue.

+3
source

All Articles