ruby on rails - Searching tags with metawhere -


i'm trying perform multi-column search on model , it's associated tags. i'm using metawhere , acts-as-taggable-on this. have model title , body has amount of tags names. i've been trying set query metawhere never returns results when try join model's tags. have variable named "str" that's being used search post model following...

post.where(:title.matches % '#{str}%' | :body.matches % '#{str}%' | {:tags => [:name.matches % '#{str}%']}).joins(:tags) 

which generates following sql...

=> "select `posts`.* `posts` inner join `taggings` on `posts`.`id` = `taggings`.`taggable_id` , `taggings`.`taggable_type` = 'post' inner join `tags` on 'taggings.tagger_id null , taggings.context = \\'tags\\'' (((`posts`.`title` '\#{str}%' or `posts`.`body` '\#{str}%') or `tags`.`name` '\#{str}%'))" 

can point me in right direction this? appreciated.

try: (assuming operator overloads enabled)

.where((:title =~ str) | (:body =~ str) | {:tags => [:name =~ str]}) 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -