Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ActiveRecord version check in Rails 4.0 #988

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).

### Fixed

- None
- [#988](https://github.com/airblade/paper_trail/pull/988) - Fix ActiveRecord
version check in `VersionConcern` for Rails 4.0


## 7.1.2 (2017-08-30)

Expand All @@ -31,7 +33,6 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).

- [#985](https://github.com/airblade/paper_trail/pull/985) - Fix RecordInvalid
error on nil item association when belongs_to_required_by_default is enabled.

## 7.1.1 (2017-08-18)

### Breaking Changes
Expand Down
2 changes: 2 additions & 0 deletions lib/paper_trail/record_trail.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module PaperTrail
# Represents the "paper trail" for a single record.
class RecordTrail
# The respond_to? check here is specific to ActiveRecord 4.0 and can be
# removed when support for ActiveRecord < 4.2 is dropped.
RAILS_GTE_5_1 = ::ActiveRecord.respond_to?(:gem_version) &&
::ActiveRecord.gem_version >= ::Gem::Version.new("5.1.0.beta1")

Expand Down
5 changes: 4 additions & 1 deletion lib/paper_trail/version_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ module VersionConcern
extend ::ActiveSupport::Concern

included do
if ActiveRecord.gem_version >= Gem::Version.new("5.0")
# The respond_to? check here is specific to ActiveRecord 4.0 and can be
# removed when support for ActiveRecord < 4.2 is dropped.
if ::ActiveRecord.respond_to?(:gem_version) &&
::ActiveRecord.gem_version >= Gem::Version.new("5.0")
belongs_to :item, polymorphic: true, optional: true
else
belongs_to :item, polymorphic: true
Expand Down