小编Ant*_*y H的帖子

有没有人得到acts_as_list在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)

acts-as-list ruby-on-rails-3

5
推荐指数
2
解决办法
6191
查看次数

如何在一个独立运行的页面上创建多个计时器-javascript?

我写了一个计时器对象,其作用类似于秒表(单击一次,计时器启动,再次单击并停止,双击并重置).如果我只激活一个计时器,一切正常.当我激活第二个计时器时,第一个计时器停止工作.当我激活第三个计时器时,第二个计时器停止工作.

我动态创建了每个计时器对象,为每个计时器提供了自己的名称(window [timer1]).但他们不是独立行事.我错过了让计时器对象彼此独立运行的原因是什么?

function Clock() {
  this.element = "";
  this.minute = 0;
  this.toggle = true;
  this.active = false;
  this.startClock = startClock;
  this.stopClock = stopClock;

function startClock() {
  minute = this.minute;
  element = this.element;
  minute = checkTime(minute);
  document.getElementById(element).innerHTML = minute;
  minute++;
  this.minute = minute;
  t=setTimeout(function(){startClock()},1000);
  this.counter = t;
}

function checkTime(i) {
    if (i<10)
    {
      i="0" + i;
    }
  return i;
}

function stopClock() {
  document.getElementById(element).innerHTML = this.minute;
  clearTimeout(t);
}

}

function initClock(ele) {
  value = document.getElementById(ele).innerHTML;

  if (typeof window[ele] == …
Run Code Online (Sandbox Code Playgroud)

javascript oop

2
推荐指数
1
解决办法
5475
查看次数

标签 统计

acts-as-list ×1

javascript ×1

oop ×1

ruby-on-rails-3 ×1