Forum: Ruby on Rails variable conditions in find queries

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Abed21abff74d51f99d8ae6ad8e5a3e9?d=identicon&s=25 (Guest)
on 2007-06-19 05:47
(Received via mailing list)
What is the correct syntax for using variables in find conditions?

I tried this but it doesnt seem to work, I also couldnt find any
documentation online

@vote = Vote.find(:all, :conditions => 'user_id = ""', :order
=> "created_at DESC", :limit => "5"          )
4317d685bafaae74c9a2dd64c545b98d?d=identicon&s=25 claudio (Guest)
on 2007-06-19 12:10
(Received via mailing list)
@vote = Vote.find(:all,
                           :conditions => ["user_id = ? ",],
                           :order => "created_at DESC",
                           :limit => 5)

If you want to put more conditions:
 :conditions => ["user_id = ? and group_id = ? ",,]

ActiveRecord quotes( the condition for you


On Jun 19, 5:46 am, "" <>
This topic is locked and can not be replied to.