model.rb
class Category < ApplicationRecord
has_many :video_categories
has_many :videos, :through => :video_categories
end
class VideoCategory < ApplicationRecord
belongs_to :video
belongs_to :category
end
class Video < ApplicationRecord
has_many :video_categories
has_many :categories, :through => :video_categories
end
我有3个型号。多对多联合。
rails_admin.rb
config.model Video do
list do
field :url
field :title
field :description
field :category, :belongs_to_association
field :views
field :votes
end
edit do
field :url do
required true
end
field :title do
required true
end
field :description do
html_attributes do
{:maxlength => 200,
:cols => 50}
end
end
field :category, :belongs_to_association
field :thumbnail
end
end
以下是浏览器中的错误: