1
0
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:
Dan Barber 2012-08-18 08:44:01 +01:00
parent 523d7f184c
commit 701d3c12ad
4 changed files with 20 additions and 2 deletions

18
.gitignore vendored Normal file
View 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

View File

@ -3,8 +3,7 @@ module Slugtastic
def has_slug name, options = { :from => :title }
before_validation do |record|
return if responds_to?(name) and send(name).present?
send("#{name}=", Slugtastic.generate_slug(send(options[:from])))
send("#{name}=", Slugtastic.generate_slug(send(options[:from]))) if send(name).nil? or send(name).blank?
end
end

View File

@ -4,6 +4,7 @@ require 'spec_helper'
class Model < SuperModel::Base
include ActiveModel::Validations::Callbacks
extend Slugtastic::ModelAdditions
attr_accessor :slug, :title
has_slug :slug, from: :title
end