2012-05-03 01:26:26 -04:00
|
|
|
class Link < ActiveRecord::Base
|
|
|
|
attr_accessible :description, :release, :url
|
|
|
|
validates :url, :presence => true, :url => true
|
|
|
|
validates :description, :presence => true
|
|
|
|
|
2012-05-03 01:37:30 -04:00
|
|
|
def self.released
|
2012-05-03 01:26:26 -04:00
|
|
|
Link.where("DATE(release) <= DATE(?)", Time.now).order("release DESC")
|
|
|
|
end
|
|
|
|
|
2012-05-03 01:37:30 -04:00
|
|
|
def self.goto(id = nil)
|
2012-05-03 01:26:26 -04:00
|
|
|
return false if nil
|
|
|
|
|
|
|
|
Link.transaction do
|
|
|
|
link = Link.find(id)
|
|
|
|
link.visits += 1
|
|
|
|
link.save
|
|
|
|
end
|
|
|
|
|
|
|
|
return link
|
|
|
|
end
|
|
|
|
end
|