Ruby on Rails Sunday, October 31, 2010

On 31 October 2010 19:36, MDM <don.mapp@gmail.com> wrote:
> Thanks Michael
> I have tried that along with other versions of '%search_item%'without
>     self.where('section = ?', '%search_item%') does not work and you
> cannot use %without a ' or "

Oops.... just spotted....
if you're trying to do a SQL query with "%" you need to use "LIKE"
instead of "="

self.where('section LIKE ?', "%#{search_item}%")

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment