forked from saurabh/personal-honor
37 lines
726 B
Ruby
37 lines
726 B
Ruby
class Honor
|
|
include Mongoid::Document
|
|
include Mongoid::Timestamps
|
|
include OrbitModel::Status
|
|
include Slug
|
|
|
|
belongs_to :honor_type
|
|
belongs_to :member_profile
|
|
|
|
field :year
|
|
field :award_name, localize: true
|
|
field :awarding_unit, localize: true
|
|
field :language
|
|
field :keywords
|
|
field :url
|
|
field :note
|
|
field :rss2_id
|
|
field :create_user_id, :type => BSON::ObjectId
|
|
field :update_user_id, :type => BSON::ObjectId
|
|
|
|
paginates_per 10
|
|
|
|
before_validation :add_http
|
|
|
|
def slug_title
|
|
self.award_name+' '+self.awarding_unit
|
|
end
|
|
|
|
protected
|
|
|
|
def add_http
|
|
unless self.url.blank? || self.url[/^http:\/\//] || self.url[/^https:\/\//]
|
|
self.url = 'http://' + self.url
|
|
end
|
|
end
|
|
|
|
end |