Skip to content

Commit

Permalink
Moved links default assignment into a before_save
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanzi committed Oct 7, 2011
1 parent 71abf5b commit 35f2fd2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/models/link.rb
Expand Up @@ -4,9 +4,10 @@ class Link < ActiveRecord::Base
:uniqueness => true,
:presence => true
validates :url, :presence => true, :url => true
after_initialize :set_defaults
before_save :set_defaults

def set_defaults
self.visits ||= 0
end

end

0 comments on commit 35f2fd2

Please sign in to comment.