Skip to content

Commit

Permalink
Feature/rails 5 comptability (#3)
Browse files Browse the repository at this point in the history
Rails 5 comptability
  • Loading branch information
islam-taha authored and aalong-tr committed Oct 8, 2019
1 parent 6488ba2 commit 24a3289
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ gem 'rake'
gem 'mysql2'
gem 'rspec'
gem 'byebug'
gem 'activerecord', '~> 4.2.0'
gem 'activerecord', '~> 5.2.3'
6 changes: 3 additions & 3 deletions lib/louisville/extensions/history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def self.included(base)
extend ::Louisville::Extensions::History::ClassMethods

# If our slug has changed we should manage the history.
after_save :delete_matching_historical_slug, :if => :louisville_slug_changed?
after_save :generate_historical_slug, :if => :louisville_slug_changed?
after_save :delete_matching_historical_slug, if: :louisville_slug_previously_changed?
after_save :generate_historical_slug, if: :louisville_slug_previously_changed?

before_destroy :destroy_historical_slugs!
end
Expand Down Expand Up @@ -63,7 +63,7 @@ def delete_matching_historical_slug

# Then we generate a new historical slug for the previous value (if there is one).
def generate_historical_slug
previous_value = self.send("#{louisville_config[:column]}_was")
previous_value = self.previous_changes[louisville_config[:column]].try(:[], 0)

return unless previous_value

Expand Down
3 changes: 3 additions & 0 deletions lib/louisville/slugger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ def louisville_slug_changed?
self.send("#{louisville_config[:column]}_changed?")
end

def louisville_slug_previously_changed?
self.send("#{louisville_config[:column]}_previously_changed?")
end

def apply_louisville_slug
value = extract_louisville_slug_value_from_field
Expand Down
2 changes: 1 addition & 1 deletion lib/louisville/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module VERSION

MAJOR = 0
MINOR = 0
PATCH = 4
PATCH = 6
PRE = nil

def self.to_s
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

require 'active_record'
require 'louisville'
require 'yaml'

begin
require 'byebug'
Expand Down

0 comments on commit 24a3289

Please sign in to comment.