Show single blog entry.
This commit is contained in:
parent
08dff24760
commit
8796d28d28
2 changed files with 12 additions and 1 deletions
|
@ -14,6 +14,7 @@ class BlogsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @blog }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue