mirror of
https://github.com/danbee/slugtastic
synced 2025-03-04 08:49:05 +00:00
Fixed final test. Added .gitignore file.
This commit is contained in:
parent
523d7f184c
commit
701d3c12ad
18
.gitignore
vendored
Normal file
18
.gitignore
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
*.gem
|
||||||
|
*.rbc
|
||||||
|
.bundle
|
||||||
|
.config
|
||||||
|
.yardoc
|
||||||
|
*.swp
|
||||||
|
Gemfile.lock
|
||||||
|
InstalledFiles
|
||||||
|
_yardoc
|
||||||
|
coverage
|
||||||
|
doc/
|
||||||
|
lib/bundler/man
|
||||||
|
pkg
|
||||||
|
rdoc
|
||||||
|
spec/reports
|
||||||
|
test/tmp
|
||||||
|
test/version_tmp
|
||||||
|
tmp
|
||||||
@ -3,8 +3,7 @@ module Slugtastic
|
|||||||
|
|
||||||
def has_slug name, options = { :from => :title }
|
def has_slug name, options = { :from => :title }
|
||||||
before_validation do |record|
|
before_validation do |record|
|
||||||
return if responds_to?(name) and send(name).present?
|
send("#{name}=", Slugtastic.generate_slug(send(options[:from]))) if send(name).nil? or send(name).blank?
|
||||||
send("#{name}=", Slugtastic.generate_slug(send(options[:from])))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@ -4,6 +4,7 @@ require 'spec_helper'
|
|||||||
class Model < SuperModel::Base
|
class Model < SuperModel::Base
|
||||||
include ActiveModel::Validations::Callbacks
|
include ActiveModel::Validations::Callbacks
|
||||||
extend Slugtastic::ModelAdditions
|
extend Slugtastic::ModelAdditions
|
||||||
|
attr_accessor :slug, :title
|
||||||
has_slug :slug, from: :title
|
has_slug :slug, from: :title
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user