Skip to content
This repository
tree: 4c1f6fbd60

Fetching latest commit…

Cannot retrieve the latest commit at this time

RailsCasts Episode #345: Hstore

Requires Ruby 1.9.2 or higher.

Commands used in this episode

rails g hstore:setup
rails g migration add_properties_to_products properties:hstore
rails g migration index_products_properties
rake db:migrate
rails c

Commands used in rails console

p = Product.first = {rating: "PG-13", runtime: 107}!["runtime"] = 123 = { ... }
Product.where("properties -> 'rating' = 'PG-13'")
Product.where("properties -> 'rating' LIKE '%G%'")
Product.where("(properties -> 'runtime')::int > 100")
Product.where("properties @> ('rating' => 'PG-13')")
Something went wrong with that request. Please try again.