0
has_many :categories
とhas_many :types
のEditor
モデルをテーブルcategories_editors
とeditors_types
で持っています。rails adminにアソシエーションの名前を表示するには? (idの代わりに)
管理インターフェイスでは、categories
の名前を見たいと思います。 types
(下の画像を参照)で動作していますが、両方の関連付けは同じ方法で定義されています。
class Editor < ApplicationRecord
has_many :categories_editors
has_many :categories, through: :categories_editors
has_many :editors_types
has_many :types, through: :editors_types
end
class Type < ApplicationRecord
has_many :editors_types
has_many :editors, through: :editors_types
end
class Category < ApplicationRecord
has_many :categories_editors
has_many :editors, through: :categories_editors
end
class CategoriesEditor < ApplicationRecord
belongs_to :editor
belongs_to :category
end
class EditorsType < ApplicationRecord
belongs_to :editor
belongs_to :type
end
誰かがアイデアを持っていますか?あなたのコラムname
の名前を変更する必要が表示され、あなたのオブジェクトの名前を持つように