Sha256: f656d2ef0885fb02a4e4b8468eccdc5579aa0448408b4468e7f16465269ce035

Contents?: true

Size: 246 Bytes

Versions: 2

Compression:

Stored size: 246 Bytes

Contents

module Sugar
  module ActiveRecord
    def slug
      read_attribute(:slug) || to_s && write_attribute(:slug, to_s.parameterize) && read_attribute(:slug)
    end

    def to_param
      slug.present? ? "#{id}-#{slug}" : id.to_s
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sugar-0.0.42 lib/sugar/active_record.rb
sugar-0.0.41 lib/sugar/active_record.rb