app/controllers/gaku/admin/templates_controller.rb in gaku_admin-0.1.1 vs app/controllers/gaku/admin/templates_controller.rb in gaku_admin-0.2.0
- old
+ new
@@ -1,72 +1,69 @@
module Gaku
- module Admin
- class TemplatesController < Admin::BaseController
+ class Admin::TemplatesController < Admin::BaseController
- responders :collection
+ responders :collection
- respond_to :js, only: %i( destroy )
- respond_to :html, only: %i( new edit index update create )
+ respond_to :js, only: %i( new create edit update destroy index )
+ respond_to :html, only: :download
- before_action :set_template, only: %i( download edit update destroy )
+ before_action :set_template, only: %i( download edit update destroy )
- def new
- @template = Template.new
- end
+ def new
+ @template = Template.new
+ end
- def create
- @template = Template.new(template_params)
- if @template.save
- set_count
- respond_with @template, location: admin_templates_path
- else
- render :new
- end
- end
-
- def edit
+ def create
+ @template = Template.new(template_params)
+ if @template.save
+ set_count
respond_with @template
+ else
+ render :new
end
+ end
- def update
- @template.update(template_params)
- respond_with @template, location: admin_templates_path
- end
+ def edit
+ respond_with @template
+ end
- def download
- send_file @template.file.path
- end
+ def update
+ @template.update(template_params)
+ respond_with @template
+ end
- def index
- @templates = Template.all
- set_count
- respond_with @templates
- end
+ def download
+ send_file @template.file.path
+ end
- def destroy
- @template.destroy
- set_count
- respond_with @template
- end
+ def index
+ @templates = Template.all
+ set_count
+ respond_with @templates
+ end
- private
+ def destroy
+ @template.destroy
+ set_count
+ respond_with @template
+ end
- def set_count
- @count = Template.count
- end
+ private
- def set_template
- @template = Template.find(params[:id])
- end
+ def set_count
+ @count = Template.count
+ end
- def template_params
- params.require(:template).permit(attributes)
- end
+ def set_template
+ @template = Template.find(params[:id])
+ end
- def attributes
- %i( name context locked file )
- end
+ def template_params
+ params.require(:template).permit(attributes)
+ end
+ def attributes
+ %i( name context locked file )
end
end
end