class Post < ActiveRecord::Base has_and_belongs_to_many :category validates_presence_of :title def to_param "#{id}-#{title}".parameterize end scope :published, lambda { where("published = ? AND date < ?", true, Time.current) } end