Ruby on Rails
Monday, August 1, 2011
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}%"])
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-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.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment