Variable conditions in find queries

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 = “@user.id”’, :order
=> “created_at DESC”, :limit => “5” )

@vote = Vote.find(:all,
:conditions => ["user_id = ? ", @user.id],
:order => “created_at DESC”,
:limit => 5)

If you want to put more conditions:
:conditions => ["user_id = ? and group_id = ? ", @user.id, @group.id]

ActiveRecord quotes(…security…) the condition for you

claudio

On Jun 19, 5:46 am, “[email protected][email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs