Sha256: 7292f9cc091f3dbf0874684c774816143595d34ee98620f3b4586515d9967de9

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require_dependency "wafflemix/application_controller"

module Wafflemix
  class PostsController < ApplicationController
    before_filter :find_page

    def index
      @posts = Post.published
      @tags = Post.tag_counts_on(:tags)
  
      respond_to do |format|
        format.html
        format.json { render json: @posts }
      end
    end

    def show
      @post = Post.find(params[:id])
      @tags = Post.tag_counts_on(:tags)
  
      respond_to do |format|
        format.html
        format.json { render json: @post }
      end
    end

    def mercury_update
      post = Post.find(params[:id])
      post.title = params[:content][:post_title][:value]
      post.body = params[:content][:post_body][:value]
      post.excerpt = params[:content][:post_excerpt][:value]
      post.save!
      render text: ""
    end

    def tagged
      @posts = Post.published.tagged_with(params[:id])
      @tags = @posts.tag_counts_on(:tags)

      respond_to do |format|
        format.html
        format.json { render json: @posts }
      end
    end
    
    private
      def find_page
        @page = Page.find_by_title("Blog")
      end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
wafflemix-0.0.4 app/controllers/wafflemix/posts_controller.rb
wafflemix-0.0.3 app/controllers/wafflemix/posts_controller.rb
wafflemix-0.0.2 app/controllers/wafflemix/posts_controller.rb
wafflemix-0.0.1 app/controllers/wafflemix/posts_controller.rb