On Aug 1, 2011, at 10:59 AM, 原田伸也 wrote:
Hi! I want to make a search box. I tried search box by using
tag_name but it didn't work.
# posts_controller.rb
@tag = Tag.find_all_by_tag_name(params[:search_string])
is work fine.But It only return all matched words.
I tried below their code to be able to fuzzy search.
But they didn't work.
@tag = Tag.find_all_by_tag_name('%' +params[:search_string]+'%')
@tag = Tag.find(:all,:conditions => ['tag_name LIKE ?',"%
{:search_string}%"])
Try this:
@tag = Tag.find(:all,conditions => ['tag_name LIKE "%?
%"',params[:search_string]]
Walter
Please help me some advise! thanks.
--
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-
[email protected].
To unsubscribe from this group, send email to [email protected]
.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en
.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.