【发布时间】:2014-04-07 20:18:57
【问题描述】:
我在我的 Rails 应用程序中为 HABTM 关联创建了一个连接表。它在模式中创建了表,但从未在应用程序中生成模型文件。它还会起作用吗?为什么没有生成文件?
这是我的迁移:
class CreateBooksAuthorsJoinTable < ActiveRecord::Migration
def change
create_table :books_authors, id: false do |t|
t.integer :book_id
t.integer :author_id
t.timestamps
end
end
end
模型
class Book < ActiveRecord::Base
has_and_belongs_to_many :feeds
end
class Author < ActiveRecord::Base
has_and_belongs_to_many :posts
end
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 rails-migrations rails-models