私有方法`import'呼吁 #

时间:2014-03-25 11:02:10

标签: ruby-on-rails activerecord methods import gem

我想问你这个错误, 对此有什么看法?如果你这样做,请告诉我。

情况如下:

  1. 首先,我想要在创建之后测试我的迁移。

      

    RAILS_ENV = test rake db:migrate

  2. 之后出现错误。

      

    /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake/alt_system.rb:32:in <module:AltSystem>': Use RbConfig instead of obsolete and deprecated Config. /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake/alt_system.rb:32:in':使用RbConfig而不是过时和弃用的配置。   /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:960:in <module:FileUtils>': Use RbConfig instead of obsolete and deprecated Config. /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:962:in':使用RbConfig代替过时和弃用的Config。   /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:965:in <module:FileUtils>': Use RbConfig instead of obsolete and deprecated Config. /usr/local/rvm/gems/ruby-2.0.0-p451/gems/rake-0.8.7/lib/rake.rb:966:in':使用RbConfig代替过时和弃用的Config。   (在/ Users / agstwn / Documents / WORK / hq_git / Publis_Server中)   syck已被删除,而是使用了psych   警告:Nokogiri是针对LibXML 2.7.3版本构建的,但动态加载了2.7.8   DEPRECATION WARNING:不推荐调用set_table_name。请改用self.table_name = 'the_name'。 (从/Users/agstwn/Documents/WORK/hq_git/Publis_Server/config/environment.rb:12调用)   == FillAppIdInCampaignPrices:迁移 - ===================================   rake aborted!发生了错误,取消了以后的所有迁移:

  3.   

    私有方法`import'调用#

    当我检查方法时,它会放在一个迁移中。

    class FillAppIdInCampaignPrices < ActiveRecord::Migration
      def self.up
        remaining_cps_attrs = {}
        CampaignPrice.find_each do |cp|
          # What we want to do is : app_ids = cp.app_ids
          # but the association to app_ids won't be available.
          records = CampaignPrice.find_by_sql([
            'SELECT campaign_price_apps.app_id FROM campaign_prices ' +
            'INNER JOIN campaign_price_apps ON campaign_prices.id = campaign_price_apps.campaign_price_id ' +
            'WHERE campaign_prices.id = ?', cp.id])
          app_ids = records.map { |record| record.app_id.to_i }
          app_ids.each do |app_id|
            remaining_cps_attrs[[cp.content_id, app_id]] = cp.attributes
          end
        end
        CampaignPrice.delete_all
        attrs = remaining_cps_attrs.map { |(cid, aid), attrs| CampaignPrice.new(attrs.merge(app_id: aid)) }
        CampaignPrice.import(attrs)
      end
      def self.down
      end
    end
    

    希望你们帮我解决这个问题。 问候。

    agstwn21

0 个答案:

没有答案