-
-
Save jakcharlton/6455763 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Product < ActiveRecord::Base | |
# our hstore column, make sure gem 'activerecord-postgres-hstore' is in your Gemfile | |
# and you've run: rails g hstore:setup | |
serialize :data, ActiveRecord::Coders::Hstore | |
# name is a string col | |
attr_accessible :data, :name | |
def self.search(query) | |
where("name @@ :q or CAST(avals(data) AS text) @@ :q", q: query) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment