class Room
has_many :room_markers
has_many :rooms, through: :room_markers
end
class Marker
...
end
class RoomMarker
belongs_to :room
belongs_to :marker
end
我有一组类如上所述。 现在我
我有三个型号: class User < ActiveRecord::Base
has_and_belongs_to_many :groups
end
class Group < ActiveRecord::Base
has_and_belongs_to_many :channels
has_and_belongs_to_many :users
end
c
Ruby on rails新手在这里。试图创建一个初学者博客应用程序,并且遇到与我的模型之间存在多对多关联的问题。 我有2个模型 - 发布,类别之间有多对多的关联。 我的问题:当我创建一个新帖子时,帖子被保存,但后类别关联不会保存在categories_posts表中。 我的代码如下。 我很欣赏你对此的意见。 post.rb class Post < ActiveRecord::Base