You could either use the find_by_sql method or the :joins method. (As 
someone has stated earlier that avoid find_by_sql for performance and 
maintanence reasons)


sample sql to put in find_by_sql in your model

select question_id from responses r1
where not exists
(select question_id from question q )


using :joins. (probably this would be better )

questions.find(  :joins => "LEFT OUTER JOIN responses ON question_id = 
responses.question_id"  :conditions => "responses.id is null")


gurus, please comment on this.

thanks,
radha.



badnaam wrote:
> I have three models, Question, Response and User
> 
> User has many question, :through Responses
> 
> My response table has 3 main columns response, question_id and
> user_id.
> 
> The use case is lets say the user can respond to 100 question, but
> during a session he responds to 20. How do I find out the ones he has
> not respondeded to. In this case the response table will have 20
> records and I woukd like to show the user the rest of the 80 he has
> not responded to.
> 
> Thanks

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to