To give a brief intro, the relationships between models used here are: 'Classification' has many 'Standards' and 'Standard' has many 'Sections'. I wanted to use a single rabl file for selecting all sections as well as for selecting a single section. Here, @section = nil indicates that we are selecting all sections.
I tried something like this:
collection @classifications, root: 'classifications', object_root: false
node do |classification|
partial('feed/shared/addressable_basic_info', :object => classification)
end
node (:standards) do |classification|
standard = @section.standard if @section != nil
classification.find_standards_by(standard).map do |standard|
partial('feed/shared/addressable_basic_info', :object => standard)
node(:sections) do
standard.find_sections_by(@section).map do |section|
partial('feed/shared/addressable_basic_info', :object => section)
node(:audience_type) { 'student'}
end
end
end
end
To give a brief intro, the relationships between models used here are: 'Classification' has many 'Standards' and 'Standard' has many 'Sections'. I wanted to use a single rabl file for selecting all sections as well as for selecting a single section. Here, @section = nil indicates that we are selecting all sections.
I tried something like this:
and it gave me an output like:
But this works well with a single map.
When I use 'each' in place of 'map', it prints out the looped object as such and it does not care about node or partials present within.
The output while using 'each' is something like:
I might be completely wrong with the usage of map. Is my approach wrong here? If so, how can I go about this?