问题 This question already has answers here : Rails HABTM setup, model object, & join_table insertion controller setup (2 answers) Closed 13 days ago . I'm new to Ruby on Rails, and I'm developing a backend API. Currently, I got 2 Active Record Models called Book and Genre . Active Record Model class Book < ActiveRecord::Base has_and_belongs_to_many :genres end class Genre < ActiveRecord::Base hast_and_belongs_to_many :books end DB Schema Model create_table :books do |t| t.string "title" end