0
关联模型Rails应用程序中,我有两个模式是这样的:如何包括active_admin
class Painting < ActiveRecord::Base
belongs_to :artist
end
class Artist < ActiveRecord::Base
belongs_to :country
def display_name
text = to_s
if birth_year
death = death_year || "----"
text += " (#{birth_year}-#{death})"
end
text += ", #{country.name}"
end
end
class Country < ActiveRecord::Base
active_admin_translates :name
end
我使用主动管理这样
ActiveAdmin.register Painting do
end
的问题比display_name
方法需要拨打国家和翻译表格。有很多艺术家,运行时间很长。我正在寻找一种方法来提高速度。
请求似乎是这样的:
SELECT "artists".* FROM "artists" WHERE "artists"."accepted" = 't' ORDER BY name
SELECT "countries".* FROM "countries" WHERE "countries"."id" = 50 ORDER BY name LIMIT 1
所有艺术家被要求这样做输入:
我能做些什么?
按照以下说明:https://github.com/josevalim/inherited_resources#overwriting-defaults – apneadiving