数据库迁移期间未知的密钥find_options

时间:2017-01-19 11:53:19

标签: ruby-on-rails

我正在尝试更新旧的Redmine插件但是当我尝试进行迁移时出现此错误。有人可以给我一些指示如何解决这个问题吗? 我尝试将find_options替换为scope,但我不确定该怎么做。

rake aborted!
ArgumentError: Unknown key: :find_options. Valid keys are: :type, :permission, :timestamp, :author_key, :scope
/home/developer/projects/redmine/redmine-3.3.1/lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb:32:in `acts_as_activity_provider'

迁移文件:

require File.join(File.dirname(__FILE__), '../../app/models', 'hudson_build')

class UpdateBuilding < ActiveRecord::Migration
  def self.up
    HudsonBuild.update_all "building = 'true'", "building = 't'"
    HudsonBuild.update_all "building = 'false'", "building = 'f'"
  end

  def self.down
    HudsonBuild.update_all "building = 't'", "building = 'true'"
    HudsonBuild.update_all "building = 'f'", "building = 'false'"
  end
end

导致问题的hudson_build.rb模型的一部分:

require 'hudson_api_error'
require 'hudson_exceptions'
require 'rexml_helper'
include RexmlHelper

class HudsonBuild < ActiveRecord::Base
  unloadable
  has_many :changesets, :class_name => 'HudsonBuildChangeset', :dependent => :destroy
  has_one :test_result, :class_name => 'HudsonBuildTestResult', :dependent => :destroy
  has_many :artifacts, :class_name => 'HudsonBuildArtifact', :dependent => :destroy
  belongs_to :job, :class_name => 'HudsonJob', :foreign_key => 'hudson_job_id'
  belongs_to :author, :class_name => 'User', :foreign_key => 'caused_by'

  validates_presence_of :hudson_job_id, :number
  validates_uniqueness_of :number, :scope => :hudson_job_id

  acts_as_event :title => Proc.new {|o| 
                                  retval = "#{l(:label_build)} #{o.job.name} #{o.number}: #{o.result}" unless o.building?
                                  retval = "#{l(:label_build)} #{o.job.name} #{o.number}: #{l(:notice_building)}" if o.building?
                                  retval
                                },
                  :description => Proc.new{|o|
                                  items = []
                                  items << o.test_result.description_for_activity if o.test_result != nil
                                  items << HudsonBuildChangeset.description_for_activity(o.changesets) if o.changesets.length > 0
                                  items.join("; ")
                                },
                  :datetime => :finished_at

  acts_as_activity_provider :type => 'hudson',
                             :timestamp => "#{HudsonBuild.table_name}.finished_at",
                             :author_key => "#{HudsonBuild.table_name}.caused_by",
                             :find_options => {:include => {:job => :project}},
                             :permission => :view_hudson

  include HudsonHelper
  extend RexmlHelper

1 个答案:

答案 0 :(得分:1)

我不知道这个插件,但我找到了这个commit

请尝试在HudsonBuild类中更改此行:

:find_options => {:include => {:job => :project}},

:scope => includes(:project),

这是example