Skip to content

Commit

Permalink
a rather nasty fix to support rails 5 (introduced by rails/rails#18233)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Cooke committed Feb 24, 2016
1 parent c9b207c commit c577de9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/authie/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c577de9

Please sign in to comment.