Sha256: 30c50755f75e2e26725d62da665c479353f69c5c298c407e500215dab12997e9
Contents?: true
Size: 691 Bytes
Versions: 10
Compression:
Stored size: 691 Bytes
Contents
require 'redde/url_generator' module Redde::Sluggable extend ActiveSupport::Concern included do validates :slug, format: { with: /\A[A-z0-9_-]*\z/i, message: 'имеет неверный формат, разрешены английские символы, знак подчеркивания "_" и дефис "-"'}, presence: true before_validation :set_slug end def set_slug self.slug = Redde::UrlGenerator.new(self, title_field).formatted_name.downcase unless slug.present? end def title_field send(title_symbol) end def title_symbol self.class::TITLE_SYMBOL rescue :title end def to_param "#{id}-#{slug.try(:downcase)}" end end
Version data entries
10 entries across 10 versions & 1 rubygems