Sha256: 63e9174fd681864d79e82686dc2baf02dcc6798df65923cc146200d920c04f14

Contents?: true

Size: 350 Bytes

Versions: 1

Compression:

Stored size: 350 Bytes

Contents

module Geopolitical
  module Helpers
    extend ActiveSupport::Concern

    included do
      before_validation :set_slug
    end

    def to_s
      name || slug
    end

    def set_slug
      self.slug ||= name
    end

    def slug= txt
      return unless txt
      self[:slug] = txt.downcase.gsub(/\s/, '-') #.gsub(/\W/, '')
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
geopolitical-0.8.0 lib/geopolitical/helpers.rb