I am currently using Act_as_taggable_on for tagging and pg_search to search through my postgresql database on my Rails 3 application.
How would I search through tags generated by the act_as_taggable_on gem with pg_search? I can view the tags of a Post by saying "Post.find(1).tag_list," but there are no "tag" columns in the Post table, so when I run the
pg_search_scope :search_by_weight, :against => {:tag_list => 'A', :title => 'B', :content => 'C'} #,:using => [:tsearch => {:prefix => true}] #:trigram, :dmetaphone]
it gives me an error because the column Post.tag_list doesn't exist in the Post table. What is it called when you can find the value through the dot connector (i.e. mission.tag_list) but when it doesn't exist in the table? I didn't know what to type. So basically, how do I pass in a non-existent column as a params?
Also, you may have noticed I commented out the
:using => [:tsearch => {:prefix => true}] #:trigram, :dmetaphone]
above. I can't seem to find how to install extra modules for Postgresql. Where do I type CREATE EXTENSION? (using ubuntu 11.10 and postgresql 9.1.3 -> and heroku for production)
A much more simple approach is just using the association and search that through pg_search which is done like this:
I just implemented this in one of my projects and it worked well (searched through tag names). Unfortunately I can't figure out how to weight an associated relationship since it says "tags" column not found in Items table.