Class: PostsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PostsController
- Defined in:
- lib/forge/app/controllers/posts_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#category ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/forge/app/controllers/posts_controller.rb', line 23 def category @post_category = PostCategory.find(params[:id]) @page_title = "Latest News | " + @post_category.title @posts = @post_category.posts.posted.paginate(:per_page => 6, :page => params[:page]) session[:page] = params[:page] if params[:page] render :template => "posts/index" end |
#feed ⇒ Object
41 42 43 44 45 46 |
# File 'lib/forge/app/controllers/posts_controller.rb', line 41 def feed @posts = Post.posted.all(:order => "created_at DESC", :limit => 10) respond_to do |format| format.rss end end |
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/forge/app/controllers/posts_controller.rb', line 5 def index @page_title = "Latest News" @posts = Post.posted if params[:month] && params[:year] # get posts based on archive month start_date = Time.parse("#{params[:year]}-#{params[:month]}-01") end_date = start_date + 1.month @posts = Post.posted.where("created_at >= ? AND created_at <= ?", start_date, end_date) @page_title += " | #{start_date.strftime("%B %Y")}" end @posts = @posts.paginate(:per_page => 6, :page => params[:page]) session[:page] = params[:page] if params[:page] respond_to do |format| format.html {} format.mobile { render :template => "mobile/posts" } end end |
#preview ⇒ Object
48 49 50 51 |
# File 'lib/forge/app/controllers/posts_controller.rb', line 48 def preview @post = Post.new(params[:post]) render :action => :show end |
#show ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/forge/app/controllers/posts_controller.rb', line 31 def show @post, @page_title = get_post flash.now[:notice] = "This post is not yet posted and will not appear on your live website." unless @post.posted? @comment = Comment.create_comment(@post, session[:comment]) if @post.allow_comments? respond_to do |format| format.html {} format.mobile { render :template => "mobile/post" } end end |