有没有人知道这些东西,我对此感到沮丧。
DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead.(called from <top (required)> at /**/config/environment.rb:12)
== FillAppIdInCampaignPrices: migrating - ===================================
rake aborted!
An error has occurred, this and all later migrations canceled:
private method `import' called for #<Class:0x007fc9285fdfe0>
我已经改变了这一点:
set_table_name
到此:
self.table_name = 'the_name'
=============================================== ===================================
这是environment.rb:
require File.expand_path('../application', __FILE__)
require 'octopus'
require Rails.root + 'lib/utils'
PublisServer::Application.initialize!
这就是迁移:
class AddApprovedToContents < ActiveRecord::Migration
class Content < ActiveRecord::Base
self.table_name = 'contents'
end
def up
add_column :contents, :approved, :boolean, default: false
add_column :articles, :approved, :boolean, default: false
Content.update_all approved: true
Article.update_all approved: true
end
def down
remove_column :contents, :approved
remove_column :articles, :approved
end
end
我找不到FillAppIdInCampaignPrices:迁移 我不知道从哪里来。
答案 0 :(得分:0)
我从来没有像你所呈现的那样创造如此错综复杂的移民,但我必须问为什么&#34;为什么&#34;你在迁移中有Contact
个班级吗?
根据this documentation,您可以在迁移中使用这样的模型:
class AddApprovedToContents < ActiveRecord::Migration
def up
add_column :contents, :approved, :boolean, default: false
add_column :articles, :approved, :boolean, default: false
reversible do |dir|
dir.up {
Content.update_all approved: true
Article.update_all approved: true
}
end
end
def down
remove_column :contents, :approved
remove_column :articles, :approved
end
end