Skip to content

Instantly share code, notes, and snippets.

@olistik
Created December 12, 2010 21:58
Show Gist options
  • Select an option

  • Save olistik/738376 to your computer and use it in GitHub Desktop.

Select an option

Save olistik/738376 to your computer and use it in GitHub Desktop.
How to use OpenHash in Rails 3
## UPDATE 2010-12-14: facets-2.9.0 and hashery-1.3.0 doesn't work with rails 3.0.3 (due to a bug of facets):
## https://github.com/rubyworks/hashery/issues#issue/6
## https://github.com/rubyworks/facets/issues/issue/31
## in your Gemfile
gem "facets"
gem "hashery"
## then execute in the shell
bundle install
## test it
$ rails console
Loading development environment (Rails 3.0.3)
ruby-1.9.2-p0 > OpenHash
=> OpenHash
ruby-1.9.2-p0 > movie = OpenHash.new
=> {}
ruby-1.9.2-p0 > movie.director = "Steven Spielberg"
=> "Steven Spielberg"
ruby-1.9.2-p0 > movie.director
=> "Steven Spielberg"
ruby-1.9.2-p0 > movie[:director]
=> "Steven Spielberg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment