I am having 3 models
Word, WordPartOfSpeech, WordSentence
Word has many WordPartOfSpeech
WordPartOfSpeech has many WordSentence
Now with the below mentioned code i am getting the nested json as i want
@words = Word.where(“words.id != ?”, params[:word_id])
respond_to do |format|
format.json { render :json => @words.as_json(:include => {:word_part_of_speeches => {:include => :word_sentences}}) }
end
But the problem is i want only those word part of speeches to be included in this json which have atleast 1 approved sentence and only those sentence that are approved
Now if i use joins the json returned is not nested and if i use include then condition does not work