sterrym/smithycms

View on GitHub
app/controllers/smithy/contents_controller.rb

Summary

Maintainability
A
2 hrs
Test Coverage
require_dependency "smithy/base_controller"

module Smithy
  class ContentsController < BaseController
    respond_to :html, :json

    def show
      @content = Smithy::Content.find(params[:id])
      respond_with @content
    end

    def new
      @content = Smithy::Content.new(filtered_params)
      respond_with @content
    end

    def create
      @content = Smithy::Content.new(filtered_params)
      @content.save
      flash.notice = "Your content was created" if @content.persisted?
      respond_with @content
    end

    def edit
      @content = Smithy::Content.find(params[:id])
      respond_with @content
    end

    def update
      @content = Smithy::Content.find(params[:id])
      flash.notice = "Your content was saved" if @content.update_attributes(filtered_params)
      respond_with @content
    end

    def destroy
      @content = Smithy::Content.find(params[:id])
      @content.destroy
      respond_with @content
    end
  end
end