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 field :awarding_unit field :language field :keywords field :url field :note 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