多くのcategory
クラスがありproducts
、各製品に 1 つのカテゴリしかない場合、モデルは次のようになります。
class Product < ActiveRecord::Base
belongs_to :category
end
この:
class Category < ActiveRecord::Base
has_many :products
end
次に、belongs_to
製品側から、次を使用して製品モデルに category_name を作成できますcreate_category
か? 製品側で使用できる自動生成メソッドを確認するにはどうすればよいですか?