1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00
danbarberphoto/app/models/photo.rb

31 lines
429 B
Ruby

class Photo < ActiveRecord::Base
has_and_belongs_to_many :categories
dragonfly_accessor :image
validates :image, presence: true
paginates_per 11
scope :enabled, -> { where(enabled: true) }
scope :featured, -> { enabled.where(featured: true) }
def to_s
title
end
def name
title
end
def log_view
if views.nil?
self.views = 1
else
self.views += 1
end
save
end
end