Show single blog entry.

This commit is contained in:
Andrew Tomaka 2012-05-05 00:08:02 -04:00
parent 08dff24760
commit 8796d28d28
2 changed files with 12 additions and 1 deletions

View file

@ -15,5 +15,6 @@ class BlogsController < ApplicationController
format.html
format.json { render :json => @blog }
end
end
end

View file

@ -1,9 +1,19 @@
class Blog < ActiveRecord::Base
attr_accessible :title, :body, :release
validates :title, :presence => true, :length { minimum: 3 }
validates :title, :presence => true, :length => { :minimum => 3 }
validates :body, :presence => true
def self.released
Blog.where("DATE(release) <= DATE(?)", Time.now).order("release DESC")
end
def self.get(id = nil)
return false if nil
blog = Blog.find(id)
return false if blog.release == nil
return blog
end
end