diff --git a/Gemfile b/Gemfile index 3f3689d..a2c0571 100644 --- a/Gemfile +++ b/Gemfile @@ -1,12 +1,12 @@ -source "http://rubygems.org" +source 'http://rubygems.org' gem 'rails', '3.1.0' -gem "rake", "~> 0.9.2.2" +gem 'rake', '~> 0.9.2.2' # gem 'rails', :git => 'git://github.com/rails/rails.git' -gem "mongoid", "~> 2.3.3" -gem "bson_ext", "~> 1.4" +gem 'mongoid', '~> 3.0' +gem 'bson_ext', '~> 1.6' if RUBY_VERSION < '1.9' - gem "ruby-debug", ">= 0.10.3" + gem 'ruby-debug', '>= 0.10.3' end diff --git a/Gemfile.lock b/Gemfile.lock index 489ee8a..78f96c1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -30,35 +30,38 @@ GEM activesupport (= 3.1.0) activesupport (3.1.0) multi_json (~> 1.0) - arel (2.2.1) - bcrypt-ruby (3.0.0) - bson (1.4.0) - bson_ext (1.4.0) - builder (3.0.0) + arel (2.2.3) + bcrypt-ruby (3.0.1) + bson (1.8.2) + bson_ext (1.8.2) + bson (~> 1.8.2) + builder (3.0.4) erubis (2.7.0) hike (1.2.1) - i18n (0.6.0) - mail (2.3.0) + i18n (0.6.1) + json (1.7.7) + mail (2.3.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) - mime-types (1.16) - mongo (1.4.0) - bson (= 1.4.0) - mongoid (2.3.3) + mime-types (1.21) + mongoid (3.0.22) activemodel (~> 3.1) - mongo (~> 1.3) + moped (~> 1.2) + origin (~> 1.0) tzinfo (~> 0.3.22) - multi_json (1.0.3) - polyglot (0.3.2) - rack (1.3.2) + moped (1.4.2) + multi_json (1.6.1) + origin (1.0.11) + polyglot (0.3.3) + rack (1.3.10) rack-cache (1.0.3) rack (>= 0.4) rack-mount (0.8.3) rack (>= 1.0.0) - rack-ssl (1.3.2) + rack-ssl (1.3.3) rack - rack-test (0.6.1) + rack-test (0.6.2) rack (>= 1.0) rails (3.1.0) actionmailer (= 3.1.0) @@ -76,23 +79,24 @@ GEM rdoc (~> 3.4) thor (~> 0.14.6) rake (0.9.2.2) - rdoc (3.9.4) - sprockets (2.0.0) + rdoc (3.12.1) + json (~> 1.4) + sprockets (2.0.4) hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) thor (0.14.6) tilt (1.3.3) - treetop (1.4.10) + treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.29) + tzinfo (0.3.35) PLATFORMS ruby DEPENDENCIES - bson_ext (~> 1.4) - mongoid (~> 2.3.3) + bson_ext (~> 1.6) + mongoid (~> 3.0) rails (= 3.1.0) rake (~> 0.9.2.2) diff --git a/lib/mongoid_session_store/mongoid_store.rb b/lib/mongoid_session_store/mongoid_store.rb index ded02f5..e47594d 100644 --- a/lib/mongoid_session_store/mongoid_store.rb +++ b/lib/mongoid_session_store/mongoid_store.rb @@ -5,11 +5,12 @@ class MongoidStore < AbstractStore class Session include Mongoid::Document - store_in :sessions + store_in collection: 'sessions' - identity :type => String + field :id, type: String + attr_accessible :id - field :data, :type => String, :default => [Marshal.dump({})].pack("m*") + field :data, type: String, default: [Marshal.dump({})].pack("m*") end # The class used for session storage. diff --git a/mongoid_session_store.gemspec b/mongoid_session_store.gemspec index f13e4b0..d62136e 100644 --- a/mongoid_session_store.gemspec +++ b/mongoid_session_store.gemspec @@ -9,5 +9,5 @@ Gem::Specification.new do |s| s.files = Dir["lib/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"] s.add_dependency('rails', "~> 3.0") - s.add_dependency('mongoid', '~> 2.3') + s.add_dependency('mongoid', '~> 3.0') end diff --git a/test/dummy/config/mongoid.yml b/test/dummy/config/mongoid.yml index 3bd30c6..3dde0df 100644 --- a/test/dummy/config/mongoid.yml +++ b/test/dummy/config/mongoid.yml @@ -1,20 +1,60 @@ -development: - host: localhost - database: dummy_development - test: - host: localhost - database: dummy_test - -# set these environment variables on your prod server -production: - host: <%= ENV['MONGOID_HOST'] %> - port: <%= ENV['MONGOID_PORT'] %> - username: <%= ENV['MONGOID_USERNAME'] %> - password: <%= ENV['MONGOID_PASSWORD'] %> - database: <%= ENV['MONGOID_DATABASE'] %> - # slaves: - # - host: slave1.local - # port: 27018 - # - host: slave2.local - # port: 27019 + # Configure available database sessions. (required) + sessions: + # Defines the default session. (required) + default: + # Defines the name of the default database that Mongoid can connect to. + # (required). + database: dummy_test + # Provides the hosts the default session can connect to. Must be an array + # of host:port pairs. (required) + hosts: + - localhost:27017 + options: + # Change whether the session persists in safe mode by default. + # (default: false) + # safe: false + + # Change the default consistency model to :eventual or :strong. + # :eventual will send reads to secondaries, :strong sends everything + # to master. (default: :eventual) + consistency: :strong + # Configure Mongoid specific options. (optional) + options: + # Configuration for whether or not to allow access to fields that do + # not have a field definition on the model. (default: true) + # allow_dynamic_fields: true + + # Enable the identity map, needed for eager loading. (default: false) + # identity_map_enabled: false + + # Includes the root model name in json serialization. (default: false) + # include_root_in_json: false + + # Include the _type field in serializaion. (default: false) + # include_type_for_serialization: false + + # Preload all models in development, needed when models use + # inheritance. (default: false) + # preload_models: false + + # Protect id and type from mass assignment. (default: true) + # protect_sensitive_fields: true + + # Raise an error when performing a #find and the document is not found. + # (default: true) + # raise_not_found_error: true + + # Raise an error when defining a scope with the same name as an + # existing method. (default: false) + # scope_overwrite_exception: false + + # Skip the database version check, used when connecting to a db without + # admin access. (default: false) + # skip_version_check: false + + # User Active Support's time zone in conversions. (default: true) + # use_activesupport_time_zone: true + + # Ensure all times are UTC in the app side. (default: false) + # use_utc: false