我正在開發一個Web應用程序與Rails 3.0.9和Postgres 9.4
我想創建has_and_belongs_to_many關聯的連接表,但執行「耙db:migrate「唯一沒有執行遷移的是遷移連接表。 Rails沒有顯示任何錯誤,只是沒有創建表。 當我進行回滾時,rails會顯示一個錯誤,因爲不能刪除表,因爲不存在。遷移has_and_belongs_to_many連接表不創建表
這裏是遷移代碼:
class CreateCampanaLocalJoinTable < ActiveRecord::Migration
def self.up
def change
create_table :campanas_locals, :id => false do |t|
t.integer :campana_id
t.integer :local_id
end
end
end
def self.down
drop_table :campanas_locals
end
end
人有一個想法?謝謝!
你嵌套起來的方法中的方法定義。難道這不會真正執行更改方法嗎?因爲它只是該方法的定義,而不是調用它的方法? – jaydel