Sha256: 3e09ff957bad23d95c192b40402a957ae6f6372c74db814174c121718903ae7c

Contents?: true

Size: 307 Bytes

Versions: 3

Compression:

Stored size: 307 Bytes

Contents

class Post < ActiveRecord::Base

  has_many :comments, :dependent => :destroy

  has_and_belongs_to_many :categories

  validates_uniqueness_of :title
  
  def to_param
    "#{id}-#{title}".parameterize
  end

  scope :published, lambda {
    where("published = ? AND date < ?", true, Time.current)
  }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
blogmodule-1.0.2 app/models/post.rb
blogmodule-1.0.1 app/models/post.rb
blogmodule-1.0.0 app/models/post.rb