Take the 2-minute tour ×

The structure I need is:

[{model}, {model}, {other model}, ...] # for jquery ui autocomplete

How can I build this structure with JBuilder? For render array they has array! method, that accepts one argument - collection. But I have more than one collection. Why it's so complicated?

share|improve this question
add comment

1 Answer

I used the method child! to solve the problem.

@Model1s.each do |m1|   
json.child!{|json| json.partial! m1,as :model1}        
@Model2s.each do |m2|   
json.child!{|json| json.partial! m2,as :model2}   

Get more from here

share|improve this answer
add comment

Your Answer


