Ruby on rails 4 在RABL中显示parent.name而不是parent.id
我有一个RABL文件:Ruby on rails 4 在RABL中显示parent.name而不是parent.id,ruby-on-rails-4,rabl,Ruby On Rails 4,Rabl,我有一个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 因
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\u page\u类属于:point\u page
和属于:auto\u类
我需要在point\u page\u class
的属性中显示的不是auto\u class
的id
,而是它的name
。但是,当然,在DB中的point\u page\u classes
表中,我只有auto\u class\u id
我需要像这样的东西:
child :point_page_classes do
attributes AutoClass.find(auto_class_id).name, :show_price
end
谢谢你的帮助 胶水
方法:
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