I have a RABL file:
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
So, point_page_class belongs_to :point_page
and belongs_to :auto_class
.
I need to show in attributes
of point_page_class
not the id
of auto_class
, but the name
of it. But, of course, in point_page_classes
table in DB I have only auto_class_id
.
I need something like:
child :point_page_classes do
attributes AutoClass.find(auto_class_id).name, :show_price
end
Thanks for any help!
glue
method did it:
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