In my latest project I needed to fetch a group of tasks who where linked to a group of categories. All that I have are the Id’s of te categories which made me write the following code
Tasks.find(:all,
:conditions => ["categorie_id IN (?)", @categories.join(',')])
It seemed to work, but apparently I didn’t test [...]
Also posted in Coding | Tagged Active Record, MySQL, Rails
ActiveRecord find and MySql ‘IN’ gotcha