No description, website, or topics provided.
Ruby JavaScript CoffeeScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

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')")