require File.dirname(__FILE__) + '/lib/core_ext' require 'sluggable_finder' module SluggableInit class << self def enable_activerecord return if ActiveRecord::Base.respond_to? :find_sluggable ActiveRecord::Base.class_eval { include SluggableFinder } associations = ActiveRecord::Associations collection = associations::AssociationCollection # to support paginating finders on associations, we have to mix in the # method_missing magic from EstadoBeta::Plugins::SluggableFinder::ClassMethods to AssociationProxy # subclasses, but in a different way for Rails 1.2.x and 2.0 (collection.instance_methods.include?(:create!) ? collection : collection.subclasses.map(&:constantize) ).push(associations::HasManyThroughAssociation).each do |klass| klass.class_eval do include SluggableFinder::Finder alias_method_chain :find, :slug end end end end end SluggableInit.enable_activerecord if (defined?(ActiveRecord) && !ActiveRecord::Base.respond_to?(:sluggable_finder))