当我尝试运行迁移时,我得到了以下信息:
NoMethodError: undefined method `column' for #<Foreigner::ConnectionAdapters::ForeignKeyDefinition:0x007fa020938740>
下面是迁移代码:
class CreateAdvertisement < ActiveRecord::Migration
def change
create_table :advertisement do |t|
t.integer :issue_id, null: false
t.string :client_name, null: false
t.decimal :size, null: false
t.decimal :price, null: false
t.decimal :commission_amount, null: false
t.string :first_payment, null: false
t.string :second_payment, null: false
t.timestamps null: false
t.foreign_key :issue
end
end
end
我安装了Foreigner 1.6.1,Rails 4.2.0。有什么想法吗?
发布于 2014-11-04 12:14:50
您或您的gem使用的是‘外国人’gem,该gem在rails 4.2.0中已弃用
您应该更新它或删除此依赖项。也许有人已经这样做了,例如我使用了'mailboxer‘gem,而'github.com/div’已经派生了这个项目来创建一个分支,所以我更改了我的Gemfile:
gem 'mailboxer', :git => 'git://github.com/div/mailboxer.git', :branch => 'rails42-foreigner'
发布于 2014-11-30 23:20:07
你不需要使用带有Rails 4.2的外国人,因为它已经内置了外键支持。语法与外国人非常相似(尽管不完全相同)。
请参阅:http://edgeguides.rubyonrails.org/4_2_release_notes.html#foreign-key-support
https://stackoverflow.com/questions/26660640
复制相似问题