WIA/app/models/blog.rb

20 lines
425 B
Ruby
Raw Normal View History

2012-05-04 23:55:58 -04:00
class Blog < ActiveRecord::Base
attr_accessible :title, :body, :release
2012-05-05 00:08:02 -04:00
validates :title, :presence => true, :length => { :minimum => 3 }
2012-05-04 23:55:58 -04:00
validates :body, :presence => true
def self.released
Blog.where("DATE(release) <= DATE(?)", Time.now).order("release DESC")
end
2012-05-05 00:08:02 -04:00
def self.get(id = nil)
return false if nil
blog = Blog.find(id)
return false if blog.release == nil
return blog
end
2012-05-04 23:55:58 -04:00
end