Skip to content

Commit

Permalink
Fix #70 with Rails 5.1 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Apr 28, 2017
1 parent 0d3eaa1 commit b0ecd1a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Expand Up @@ -2,4 +2,4 @@ source 'https://rubygems.org'

gemspec

gem 'rails', '~> 5.0.0'
gem 'rails', '~> 5.1.0'
5 changes: 5 additions & 0 deletions gemfiles/Gemfile-5-1
@@ -0,0 +1,5 @@
source 'https://rubygems.org'

gemspec :path => '..'

gem 'rails', '5.1.0'
4 changes: 2 additions & 2 deletions lib/second_level_cache/active_record/finder_methods.rb
Expand Up @@ -19,7 +19,6 @@ def find_one(id)
return super(id) unless select_all_column?

id = id.id if ActiveRecord::Base == id

if cachable?
record = @klass.read_second_level_cache(id)
if record
Expand Down Expand Up @@ -61,12 +60,13 @@ def first(limit = nil)

private

# readonly_value - active_record/relation/query_methods.rb Rails 5.1 true/false
def cachable?
limit_one? &&
order_values.blank? &&
includes_values.blank? &&
preload_values.blank? &&
readonly_value.nil? &&
!readonly_value &&
joins_values.blank? &&
!@klass.locking_enabled? &&
where_clause_match_equality?
Expand Down
4 changes: 2 additions & 2 deletions second_level_cache.gemspec
Expand Up @@ -30,8 +30,8 @@ Gem::Specification.new do |gem|
gem.require_paths = ['lib']
gem.version = SecondLevelCache::VERSION

gem.add_runtime_dependency 'activesupport', ['>= 5.0.0.beta3', '< 5.1.0']
gem.add_runtime_dependency 'activerecord', ['>= 5.0.0.beta3', '< 5.1.0']
gem.add_runtime_dependency 'activesupport', ['>= 5.0.0', '< 5.2']
gem.add_runtime_dependency 'activerecord', ['>= 5.0.0', '< 5.2']

gem.add_development_dependency 'sqlite3'
gem.add_development_dependency 'rake'
Expand Down

0 comments on commit b0ecd1a

Please sign in to comment.