0

是否有可能在一个有一个字段并且属于许多表?

就像最喜欢的:

create_table :messages_users, :id => false, :force => true do |t|
  t.integer :message_id, :null => false
  t.integer :user_id, :null => false

  t.boolean :favorite, :null => false

  t.timestamps
end

感谢 ActiveRecord,我看到时间戳运行良好。但是当我尝试将收藏夹添加到表格中然后我尝试:

Message.first.users << User.first

然后我收到此错误消息:

ActiveRecord::StatementInvalid: SQLite3::SQLException: messages_users.favorite 不能为 NULL: INSERT INTO "messages_users" ("created_at", "message_id", "updated_at", "user_id") VALUES ('''2010-05-27 06:07 :50.721512''', 1, '''2010-05-27 06:07:50.721512''', 1)

我想使用一个 habtm,我不喜欢 has_many foo 虽然酒吧协会:)

那可能吗?

非常感谢。

4

1 回答 1

1

不,这是不可能的。
尽管 bar 使用 has_many foo。

于 2010-05-27T07:07:21.837 回答