Skip to content
Browse files

clean url

  • Loading branch information...
1 parent 26c64ec commit e352d217a7ca898a0d03c5af19a2b3f2a33aeb4a @micahbrich committed Feb 15, 2009
Showing with 10 additions and 0 deletions.
  1. +10 −0 app/models/comment.rb
View
10 app/models/comment.rb
@@ -5,10 +5,20 @@ class Comment < ActiveRecord::Base
validates_presence_of :name
validates_presence_of :email
validates_presence_of :body
+ before_save :clean_url
def self.post
Comment.find_by_post_id(self.post_id)
end
+ def clean_url
+ unless self.website.blank?
+ unless self.website =~ /https?:\/\/.*/
+ write_attribute :website, "http://" + self.website.to_s
+ else
+ write_attribute :website, self.website
+ end
+ end
+ end
end

0 comments on commit e352d21

Please sign in to comment.
Something went wrong with that request. Please try again.