Forum: Ruby on Rails Newbie - list based on joined query?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nick C. (Guest)
on 2006-04-22 18:08
I'm retrieving a list of tasks to display in a page using

@delegatedtask_pages, @delegatedtasks = paginate :tasks, :conditions =>
"user_id = " + session[:user_id].to_s + " percent_complete <> 100",
:order_by => 'due_on asc'

I'd like to only list the tasks which have been assigned to other
people. I have a table called assigned_tasks which links my tasks to the
users. A straight SQL query to accomplish this might be

SELECT * FROM tasks INNER JOIN assigned_tasks ON tasks.id =
assigned_tasks.task_id WHERE tasks.user_id = x AND
assigned_tasks.user_id <> x

How do I accomplish this with rails?
This topic is locked and can not be replied to.