I have three tables — stores, addresses and sales. Each store has one or more addresses. Each store also has one or more sales. These relationships are defined in my models. I have a Rabl API that is returning information about sales. I can easily access the store information by using child as follows:
object @sales
attributes :name, :description
child :store do
attributes :id, :name
end
However, how do I access the addresses information pertaining to that store? There is no direct relationship between sales and addresses specified in the model; the relationship is between stores and addresses.
You can nest your child elements like so
see ‘Deep Nesting’ at https://github.com/nesquena/rabl