# Active record find placeholders and types

**URL:** <https://www.ruby-forum.com/t/active-record-find-placeholders-and-types/143179>\
**Category:** Rails\
**Created:** [July 16, 2008, 1:56am UTC](https://www.ruby-forum.com/t/active-record-find-placeholders-and-types/143179 "2008-07-16T01:56:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ppjunty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/aeb1de/32.png) [@ppjunty](https://www.ruby-forum.com/u/ppjunty)\
**Post date:** [July 16, 2008, 1:56am UTC](https://www.ruby-forum.com/t/active-record-find-placeholders-and-types/143179/1 "2008-07-16T01:56:09Z")

</div>

the params hash can be used to replace  
placeholders in find conditions, like:

Product.find conditions =\> [“type\_id = :type\_id”, params]

this will generate the sql statement:

… WHERE type\_id = ‘1’… (with apostrophes)

that works for mysql, but i wonder if it works for  
all databases. would it be safer to pass the correct  
format? like

… conditions =\> [“type\_id = ?”, params[:type\_id].to\_i]

this generates the sql statement:

… WHERE type\_id = 1… (without apostrophes)
