Hi folks,
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'm sending this to some JavaScript using Rails' to_json method like this:
render :layout => false , :json => @child.to_json(
:include => {
:observations => {
:include => :photos,
:methods => [:key, :title, :subtitle]
}
},
:except => [:password]
)
This works perfectly. Observations are retrieved fine 'through' the join table (childviews).
However, I also want to get at data that sits in the childviews join table; specifically the value for 'needs_edit'.
I can't figure out how to get at this data in a to_json call.
Can anyone help me? Many thanks in advance.
qryss