# find all records where name starts with the first char of my_string
find(:all, :conditions => ["name_column LIKE ?",
"#{my_string.first}%"])
On 2/19/07, Drew Olson
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> All -
>
> I want to find a collection of records where name begins with the same
> letter as my_string. How would I do that? Something along the lines of:
>
> Records.find(:all,:conditions=>{:name=>my_string[0].chr})
>
> Thanks,
> Drew
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---