Using Rack :: Session :: Datamapper

The mkristgan rack_datamapper gem says that it "can be wrapped for use in a specific environement, that is, Rack :: Session :: DataMapper".

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

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

You probably don't want to do this.

The answer below is great, but upon careful examination, I realized that I should not do this. Instead, I put user_id, ip and name (for convenience) in a cookie and protect it.

+3
source share
1 answer

This stone 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 the facility session[]on your own.

+5
source

Source: https://habr.com/ru/post/1720388/


All Articles