Sha256: 544dbd6385e427944e92461cc06f60d9937ad5212e908cf78ccbfc30051842b7

Contents?: true

Size: 830 Bytes

Versions: 4

Compression:

Stored size: 830 Bytes

Contents

class BlogController < ApplicationController

  def index
    @posts = Page.for_blog.published.order('published_at desc').paginate(:page => params[:page], :per_page => 20)
    respond_to do |format|
      format.html { render :layout => 'blog' }
      format.atom
    end
  end

  def by_tag
    # this is necessary to deal with instances when no posts are present for that tag
    @tag_name = params[:id]
    # this little hack is necessary because globalize won't let me access the tag directly by name
    tag = Tag::Translation.find_by( locale: I18n.locale.to_s, name: @tag_name )
    if tag.present?
      @tag = Tag.find(tag.tag_id)
      @posts = @tag.pages.published.order('published_at desc').paginate(:page => params[:page], :per_page => 20)
      render :layout => 'blog'
    else
      @posts = nil
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tkh_content-0.10.10 app/controllers/blog_controller.rb
tkh_content-0.10.9 app/controllers/blog_controller.rb
tkh_content-0.10.8 app/controllers/blog_controller.rb
tkh_content-0.10.7 app/controllers/blog_controller.rb