# Structuring a find that looks at the first letter of a field

**URL:** <https://www.ruby-forum.com/t/structuring-a-find-that-looks-at-the-first-letter-of-a-field/163517>\
**Category:** Rails\
**Created:** [March 21, 2009, 9:01am UTC](https://www.ruby-forum.com/t/structuring-a-find-that-looks-at-the-first-letter-of-a-field/163517 "2009-03-21T09:01:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [March 21, 2009, 9:01am UTC](https://www.ruby-forum.com/t/structuring-a-find-that-looks-at-the-first-letter-of-a-field/163517/1 "2009-03-21T09:01:18Z")

</div>

I guess the subject is fairly self-explanatory. I’m pretty new to RoR,  
but I’d like to learn how to structure a find that looks at the first  
character of a field, say firstname, to find those that match a  
parameter passed in to the controller.

Hopefully it’s not too difficult. 😕  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rjsquire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/74df32/32.png) [@rjsquire](https://www.ruby-forum.com/u/rjsquire)\
**Post date:** [March 21, 2009, 9:28am UTC](https://www.ruby-forum.com/t/structuring-a-find-that-looks-at-the-first-letter-of-a-field/163517/2 "2009-03-21T09:28:21Z")

</div>

On 21 Mar., 09:01, Robert S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I guess the subject is fairly self-explanatory. I’m pretty new to RoR,  
> but I’d like to learn how to structure a find that looks at the first  
> character of a field, say firstname, to find those that match a  
> parameter passed in to the controller.
> 
> Hopefully it’s not too difficult. 😕  
> Thanks in advance.

@person = Person,find(:all, :conditions =\> [“firstname LIKE ?%”, params  
[:letter]]

The question mark is replaced with params[:letter]. There is plenty of  
material on the LIKE keyword on the internet, so if you don’t know  
what it does, go ahead and do some research.

–  
Cheers,  
David K.  
[http://twitter.com/rubyguy](http://twitter.com/rubyguy)
