Question

mkristgan's rack_datamapper gem says that it "can be wrapped to be used in a specific environement, i.e. Rack::Session::Datamapper".

Unfortunately, I don't know quite enough about Ruby to accomplish this task yet –Modules/Classes in Ruby are still above my head (coming from PHP).

Can anyone offer assistance with using rack_datamapper to implement Rack::Session::Datamapper?

You probably don't want to do this anyway.

The answer below is great, but upon closer consideration, I realized I shouldn't do it anyway. Instead, I'm placing the user_id, ip and first name (for convenience) in a cookie and protecting it.

Was it helpful?

Solution

This gem should help:

In Sinatra just add:

use Rack::Session::Moneta,
   store: Moneta.new(:DataMapper, setup: (ENV['DATABASE_URL'] || "sqlite://#{Dir.pwd}/development.db"))

and use session[] object at will.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top