iamtoc
iamtoc

Reputation: 1709

How to use an array in the condition as a filter - Ruby Rails

array_users = ["3581", "3592", "3665", "3730"]

@records = Model.find(
           :all, 
           :order => 'date desc', 
           :group => :date, 
           :conditions => {
                 :client_id => current_user.client.id,  
                 :user_id is present in array_users # <------------------
           })

How would one make certain that only the records returned have a user_id that is present in array_users using Rails 2.3.9?

Upvotes: 1

Views: 225

Answers (1)

cam
cam

Reputation: 14222

:conditions => {
  :client_id => current_user.client.id,  
  :user_id => array_users
})

See the guide for all the possibilities with the hash conditions.

Upvotes: 4

Related Questions