From 8796d28d280d46de5167b5940c088403aaf84513 Mon Sep 17 00:00:00 2001 From: Andrew Tomkaa Date: Sat, 5 May 2012 00:08:02 -0400 Subject: [PATCH] Show single blog entry. --- app/controllers/blogs_controller.rb | 1 + app/models/blog.rb | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb index 806b175..fbac5ba 100644 --- a/app/controllers/blogs_controller.rb +++ b/app/controllers/blogs_controller.rb @@ -14,6 +14,7 @@ class BlogsController < ApplicationController respond_to do |format| format.html format.json { render :json => @blog } + end end end diff --git a/app/models/blog.rb b/app/models/blog.rb index db77900..f12aa30 100644 --- a/app/models/blog.rb +++ b/app/models/blog.rb @@ -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