Convert Postgres tables to Ruby hashes
This may not be readily useable, but...
With Postgres' hstore type you can convert tables into Ruby hashes almost natively. With a little bit of tweaking in Ruby it's drop-dead simple.
Person.find_by_sql("SELECT '{' || regexp_replace(hstore(t)::varchar,'NULL','nil', 'g') || '}' FROM people as t").map do |p|
eval p.hstore
end
Written by Jason Rogers
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#