Sha256: cef166fd66620ee326342c546c981d435817035b9cae29b8262c69667f9d8b94

Contents?: true

Size: 475 Bytes

Versions: 1

Compression:

Stored size: 475 Bytes

Contents

class Topic
  include Mongoid::Document
  
  field :title,       :type => String
  field :slug,        :type => String
  field :post_types,  :type => Array
  
  validates :title, :presence => true
  before_create :generate_slug
   
  scope :for_type, lambda{ |type| where(:post_types => type) }
  scope :for_editing, lambda{ |klass, inst| ascending(:title) }
  
  def generate_slug
    return true unless self.slug.to_s.blank?
    self.slug = self.title.to_slug
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
transit-0.0.2 app/models/topic.rb