1

I've set up a Virtual Attribute tagging system as shown by Ryan Bates here: http://railscasts.com/episodes/167-more-on-virtual-attributes

The system works really well for applying tags to my models and is something I implemented into my system a couple of days ago. I then went in and followed the simple search tutorial by Ryan Bates here: http://railscasts.com/episodes/37-simple-search-form. My issue is that now my search form searches though names and I just happen to have implemented tags - it only makes sense for me to also be searching the tags. Unfortunately I'm not extremely experienced in Ruby on Rails and the only way I could even get it to kind of work was to do a bunch of loops that looped around everything and even then I couldn't figure out how to search the array I'd got (and the loops made everything very sluggish).

Does anyone know how I could do something like this?

4

1 回答 1

1

我最终使用了 Sunspot,如下所示: http ://railscasts.com/episodes/278-search-with-sunspot

使用如下所示的代码:

text :taggings do
        taggings.map{ |tagging| tagging.tag.name }
end
于 2011-08-14T21:21:26.913 回答