announcement-test/app/models/bulletin.rb

25 lines
418 B
Ruby

class Bulletin
include Mongoid::Document
include Mongoid::Timestamps
field :title, type: String, localize: true
field :body, type: String, localize: true
field :uid, type: String
# include Slug
def to_param
I18n.locale
title.parameterize
end
def self.find_by_param(input)
self.find_by(uid: input)
end
def generate_uid
self.uid = rand(36**8).to_s(36)
self.save
end
end