Using Rack::Session::Datamapper
mkristgan's rack_datamapper gem says that it "can be wrapped to be used in 开发者_如何学Pythona 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.
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.
精彩评论