Skip to content

Commit

Permalink
Revert "Defer loading of ActiveRecord to avoid config issues"
Browse files Browse the repository at this point in the history
This reverts commit 4bd4300.
  • Loading branch information
jhawthorn committed Apr 21, 2018
1 parent 915a8e2 commit bfcf57b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 17 deletions.
1 change: 0 additions & 1 deletion lib/friendly_id.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
require "friendly_id/object_utils"
require "friendly_id/configuration"
require "friendly_id/finder_methods"
require 'friendly_id/railtie' if defined?(Rails)

=begin
Expand Down
7 changes: 2 additions & 5 deletions lib/friendly_id/object_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module FriendlyId
# Instances of these classes will never be considered a friendly id.
# @see FriendlyId::ObjectUtils#friendly_id
UNFRIENDLY_CLASSES = [
ActiveRecord::Base,
Array,
FalseClass,
Hash,
Expand Down Expand Up @@ -58,15 +59,11 @@ def unfriendly_id?
true
end
end

def self.mark_as_unfriendly(klass)
klass.send(:include, FriendlyId::UnfriendlyUtils)
end
end

Object.send :include, FriendlyId::ObjectUtils

# Considered unfriendly if object is an instance of an unfriendly class or
# one of its descendants.

FriendlyId::UNFRIENDLY_CLASSES.each { |klass| FriendlyId.mark_as_unfriendly(klass) }
FriendlyId::UNFRIENDLY_CLASSES.each { |klass| klass.send(:include, FriendlyId::UnfriendlyUtils) }
9 changes: 0 additions & 9 deletions lib/friendly_id/railtie.rb

This file was deleted.

2 changes: 0 additions & 2 deletions test/object_utils_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ class ObjectUtilsTest < TestCaseClass
end

test "ActiveRecord::Base instances should be unfriendly_ids" do
FriendlyId.mark_as_unfriendly(ActiveRecord::Base)

model_class = Class.new(ActiveRecord::Base) do
self.table_name = "authors"
end
Expand Down

0 comments on commit bfcf57b

Please sign in to comment.