Ruby on Rails Sunday, October 31, 2010

Wow Thanks Michael
After all this time.
Both of these works which do you think is best.
self.where('section LIKE ?', "%#{search_item}%")
self.where('section LIKE ?', '%'+search_item+'%')
I can now get back to the remote => ajax call.
Pure joy Thanks again Don

On Oct 31, 7:40 pm, Michael Pavling <pavl...@gmail.com> wrote:
> On 31 October 2010 19:36, MDM <don.m...@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