WIA/app/models/link.rb

25 lines
555 B
Ruby
Raw Normal View History

class Link < ActiveRecord::Base
attr_accessible :description, :release, :url
validates :url, :presence => true#, :url => true
validates :description, :presence => true
def self.released
Link.where("DATE(release) <= DATE(?)", Time.now).order("release DESC")
end
def self.get_and_count(id = nil)
return false if nil
link = nil
Link.transaction do
link = Link.find(id)
2012-05-04 10:44:22 -04:00
#need to rate limit visits increment
link.increment!(:visits)
end
return false if link.release == nil
return link
end
end