Your relationship of order.id to progresses.user_id confuses me. If you
have progresses.order_id then you would be able to do this with find. Is
there a reason why you''re associating the order with user_id?
On 6/13/06, john Bu <burmjohn@gmail.com> wrote:>
> Hello all,
>
> I am trying to figure out how to do this with find instead of doing it
> via find_by_sql
>
> For example I am trying to list all my completed orders, however I need
> to check the progresses table to make sure the "currentlevel" in
the
> progress table equals
> "endlevel" in the orders table.
>
> The sql below works fine, but I am just curious how to do it another
> way.
>
> def completed
>
> @orders = Order.find_by_sql ("SELECT * FROM orders, progresses WHERE
> orders.id = progresses.user_id AND orders.endlevel >
progresses.currentlevel AND orders.process =1 ")
>
> end
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails@lists.rubyonrails.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060613/a593e8ca/attachment.html