Reputation: 35
I added an object nested in another object using the model. Just like this:
Ingresso model ->
def as_json(options=nil)
super(:include => [:usuario, :tipo_de_ingresso])
end
In tipo_de_ingresso
model, I want to add another object nested. here:
def as_json(options=nil)
super(:include => :entradas)
end
But when I get the the ingressos.json
, I lost entradas
. If I get tipo_de_ingressos.json
, entradas
are nested, ok, but when I get ingressos.json
, they are not there.
How can I get entradas
nested in tipo_de_ingresso
when I call ingresso
?
Upvotes: 1
Views: 2128
Reputation: 3067
Try this,
# /app/models/Ingresso.rb
def as_json(options=nil)
super(:include => [:usuario => {}, :tipo_de_ingresso => { :include => :entradas }])
end
EDIT:
changed [:usuario, ...
to [:usuario => {}, ...
Upvotes: 5