Forum: Ruby on Rails Find collection where :name beings with a letter

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Drew O. (Guest)
on 2007-02-19 17:53
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:


Chris H. (Guest)
on 2007-02-19 18:22
(Received via mailing list)
# find all records where name starts with the first char of my_string
find(:all, :conditions => ["name_column LIKE ?", "#{my_string.first}%"])
This topic is locked and can not be replied to.