I would say MongoDB, but if for some reasons you prefer to use ordinary database you can take a look at PostgreSQL and HStore extension: http://www.postgresql.org/docs/9.2/static/hstore.html
there are gems for using it in rails: https://github.com/engageis/activerecord-postgres-hstore
and a Railscast episode: http://railscasts.com/episodes/345-hstore