我有一个RABL文件:
collection :@points
attributes :id, :point_type, :name, :coordinates
child :point_pages do
attributes :point_page_type
child :point_page_classes do
attributes :auto_class_id, :show_price # I need to change this line
end
end
所以,point_page_class belongs_to :point_page
和belongs_to :auto_class
。
我需要在attributes
的{{1}}中显示point_page_class
id
,而不是auto_class
。name
。但是,当然,在DB的point_page_classes
表中我只有auto_class_id
。
我需要类似的东西:
child :point_page_classes do
attributes AutoClass.find(auto_class_id).name, :show_price
end
感谢您的帮助!
答案 0 :(得分:0)
glue
方法做到了:
collection :@points
attributes :id, :point_type, :name, :coordinates
child :point_pages do
attributes :point_page_type
child :point_page_classes do
attributes :show_price
glue(:auto_class) do
attributes :name
end
end
end