Sha256: d49a9881bcac001b27649267107e485a3597cdf1c81568cbd0f24e3d727207b4

Contents?: true

Size: 1.64 KB

Versions: 8

Compression:

Stored size: 1.64 KB

Contents

# -*- encoding : utf-8 -*-
module MustacheRender::Manage
  class TemplatesController < BaseController
    before_filter :load_folder_record

    def show
      @mustache_render_template = MustacheRenderTemplate.find params[:id]
    end

    def new
      @mustache_render_template = MustacheRenderTemplate.new(:folder_id => params[:folder_id])

    end

    def edit
      @mustache_render_template = MustacheRenderTemplate.find params[:id]

    end

    def create
      @mustache_render_template = MustacheRenderTemplate.new(params[:mustache_render_template].merge(
        :create_user_id => mustache_render_manager.try(:id),
        :last_user_id   => mustache_render_manager.try(:id)
      ))

      if @mustache_render_template.save
        redirect_to mustache_render_manage_folder_template_url(
          :folder_id => @mustache_render_template.folder_id, :id => @mustache_render_template
        )
      else
        render :new
      end
    end

    def update
      @mustache_render_template = MustacheRenderTemplate.find params[:id]

      @mustache_render_template.update_attributes(params[:mustache_render_template].merge(
        :last_user_id => mustache_render_manager.try(:id)
      ))

      if @mustache_render_template.errors.empty?
        redirect_to mustache_render_manage_folder_template_url(
          :folder_id => @mustache_render_template.folder_id, :id => @mustache_render_template
        )
      else
        render :edit
      end
    end

    def destroy
      # TODO: 是否增加删除功能
    end

    protected

    def load_folder_record
      @mustache_render_folder = MustacheRenderFolder.find params[:folder_id]
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mustache_render-0.0.15 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb
mustache_render-0.0.14 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb
mustache_render-0.0.13 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb
mustache_render-0.0.12 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb
mustache_render-0.0.10 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb
mustache_render-0.0.9 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb
mustache_render-0.0.7 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb
mustache_render-0.0.6 lib/mustache_render/controllers/mustache_render/manage/templates_controller.rb