I have three models (simplified here):
class Child < ActiveRecord::Base
has_many :childviews, :dependent => :nullify
has_many :observations, :through => :childviews
end
class Childview < ActiveRecord::Base
belongs_to :observation
belongs_to :child
end
class Observation < ActiveRecord::Base
has_many :childviews, :dependent => :nullify
has_many :children, :through => :childviews
end
I am posting this to some kind of JavaScript using the to_json Rails method as follows:
render :layout => false , :json => @child.to_json(
:include => {
:observations => {
:include => :photos,
:methods => [:key, :title, :subtitle]
}
},
:except => [:password]
)
It works great. Cases are retrieved "through" the table of connections (childviews).
However, I also want to get the data that is in the childviews connection table; in particular, the value for 'needs_edit'.
I cannot figure out how to get this data in a to_json call.
Can anyone help me? Thank you very much in advance.
qryss
source
share