Orbit/vendor/built_in_modules/news/app/models/news_bulletin_link.rb

24 lines
513 B
Ruby
Raw Normal View History

2012-04-29 22:27:38 +00:00
class NewsBulletinLink
include Mongoid::Document
include Mongoid::Timestamps
field :url
2012-07-25 19:37:07 +00:00
field :title, localize: true
2012-04-29 22:27:38 +00:00
field :should_destroy, :type => Boolean
belongs_to :news_bulletin
before_validation :add_http
validates :url, :presence => true, :format => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
protected
def add_http
unless self.url[/^http:\/\//] || self.url[/^https:\/\//]
self.url = 'http://' + self.url
end
end
2012-04-29 22:27:38 +00:00
end