class Project < ActiveRecord::Base
attr_accessible :description, :title, :year, :location
belongs_to :user
has_attachments :images, accept: [:jpg, :png, :gif]
validates :user_id, presence: true
validates :title, presence: true
default_scope order: 'projects.created_at DESC'
end
scope :with_images, self.images.count > 0
scope :with_images {:joins => [:images], :conditions => "images.project_id IS NOT NULL"}
def self.with_images
all.reject{|t| t.images.empty?}
end