Sha256: c1688da9e044e2c30456cf7405a1bb20925db4984df34478bad8ab02ab2b0a72

Contents?: true

Size: 385 Bytes

Versions: 13

Compression:

Stored size: 385 Bytes

Contents

require "friendly_id"

# This override must handle both the situation where locale column has been
# added to the slugs table, and also the situation where it has not.
#
FriendlyId::Slug.class_eval do
  default_scope { column_names.include?("locale") ? where(locale: ::Mobility.locale) : all }

  before_save do
    self.locale ||= ::Mobility.locale if respond_to?(:locale=)
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
friendly_id-mobility-1.0.4 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-1.0.3 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-1.0.2 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-1.0.1 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-1.0.0 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.5.5 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.5.4 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.5.3 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.5.2 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.5.1 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.4.0 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.3.1 lib/friendly_id/slug_decorator.rb
friendly_id-mobility-0.3.0 lib/friendly_id/slug_decorator.rb