Skip to content
Chandan Kumar

Moneta session store on Heroku

ruby, heroku, redis1 min read

Snippet to use Redis as session store on Heroku with Moneta Gem. I have no idea why I did not had tried it out before, but looks pretty neat. Please leave a comment in case you have any opinion about the Gem itself.

Somewhere in config

{% highlight ruby %}

1# Set session store
2if(ENV["RACK_ENV"] == 'development')
3 # use localhost for development
4 use Rack::Session::Moneta, store: :Redis
5elsif(ENV["RACK_ENV"] == 'production')
6 url = ENV["REDISTOGO_URL"]
7 uri = URI.parse url
8 use Rack::Session::Moneta, store: Moneta.new(:Redis, host: uri.host, port: uri.port, password: uri.password)
9end

{% endhighlight %}

I had to post this as I wasted 3 hours trying to figure out how to get it working. BTW I got that sample config in Padrino app.rb and it works just

Comments

Copyleft. WTH
Theme by LekoArts