Ruby on rails 4 Rails自定义管理gem
我有位置,音乐会和艺术家模型Ruby on rails 4 Rails自定义管理gem,ruby-on-rails-4,rails-admin,rails-administrate,Ruby On Rails 4,Rails Admin,Rails Administrate,我有位置,音乐会和艺术家模型 class Location < ApplicationRecord has_many :concerts, dependent: :destroy has_many :artists, through: :concerts end class Concert < ApplicationRecord belongs_to :location belongs_to :artist end class Location < Appl
class Location < ApplicationRecord
has_many :concerts, dependent: :destroy
has_many :artists, through: :concerts
end
class Concert < ApplicationRecord
belongs_to :location
belongs_to :artist
end
class Location < ApplicationRecord
has_many :concerts, dependent: :destroy
has_many :artists, through: :concerts
end
类位置
我现在正在使用rails管理器,现在我想定制rails管理器gem,在添加新音乐会时不显示id,而是在那里获得位置和艺术家名称,而不是那里的id。我已将屏幕截图附在那里。在您的位置和艺术家仪表板中,您需要定义一个
显示资源方法:
class LocationDashboard < Administrate::BaseDashboard
def display_resource(location)
location.name # or whatever attribute you want to use
end
# ...
end
class LocationDashboard
在你的艺术家仪表板上也做同样的事情,你应该准备好了:)
有关如何在位置和艺术家仪表板中自定义仪表板检查的更多详细信息,您需要定义一种显示资源的方法:
class LocationDashboard < Administrate::BaseDashboard
def display_resource(location)
location.name # or whatever attribute you want to use
end
# ...
end
class LocationDashboard
在你的艺术家仪表板上也做同样的事情,你应该准备好了:)
有关如何自定义仪表板的更多详细信息,请查看