Show single blog entry.
This commit is contained in:
parent
08dff24760
commit
8796d28d28
2 changed files with 12 additions and 1 deletions
|
@ -15,5 +15,6 @@ class BlogsController < ApplicationController
|
||||||
format.html
|
format.html
|
||||||
format.json { render :json => @blog }
|
format.json { render :json => @blog }
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
class Blog < ActiveRecord::Base
|
class Blog < ActiveRecord::Base
|
||||||
attr_accessible :title, :body, :release
|
attr_accessible :title, :body, :release
|
||||||
validates :title, :presence => true, :length { minimum: 3 }
|
validates :title, :presence => true, :length => { :minimum => 3 }
|
||||||
validates :body, :presence => true
|
validates :body, :presence => true
|
||||||
|
|
||||||
def self.released
|
def self.released
|
||||||
Blog.where("DATE(release) <= DATE(?)", Time.now).order("release DESC")
|
Blog.where("DATE(release) <= DATE(?)", Time.now).order("release DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get(id = nil)
|
||||||
|
return false if nil
|
||||||
|
|
||||||
|
blog = Blog.find(id)
|
||||||
|
|
||||||
|
return false if blog.release == nil
|
||||||
|
|
||||||
|
return blog
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue