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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5b64a6e0-76d1-41d8-ac9a-c1a9ff732b04%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.