From c577de92576577e210cae09c9cf215824477584e Mon Sep 17 00:00:00 2001 From: Adam Cooke Date: Wed, 24 Feb 2016 09:00:33 +0000 Subject: [PATCH] a rather nasty fix to support rails 5 (introduced by rails/rails#18233) --- lib/authie/session.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/authie/session.rb b/lib/authie/session.rb index b49a7d8..ad8fe71 100644 --- a/lib/authie/session.rb +++ b/lib/authie/session.rb @@ -12,7 +12,11 @@ class NoParentSessionForRevert < Error; end # Relationships belongs_to :user, {:polymorphic => true}.merge(Authie.config.user_relationship_options) - belongs_to :parent, :class_name => "Authie::Session" + parent_options = {:class_name => "Authie::Session"} + if ActiveRecord::VERSION::MAJOR >= 5 + parent_options[:optional] = true + end + belongs_to :parent, parent_options # Scopes scope :active, -> { where(:active => true) } @@ -209,7 +213,7 @@ def self.start(controller, params = {}) session.browser_id = cookies[:browser_id] session.login_at = Time.now session.login_ip = controller.request.ip - session.save + session.save! session end