plugins/report/app/controllers/reports_controller.rb in admin-sys-1.0.2 vs plugins/report/app/controllers/reports_controller.rb in admin-sys-1.1.0
- old
+ new
@@ -1,62 +1,62 @@
-class ReportsController < ApplicationController
- before_action :set_report, only: [:show, :edit, :update, :destroy]
-
- def index
- @reports = Report.all.page(params[:page]).per(50)
- end
-
- def show
- @data = @report.report_date(params)
- #@result = @report.get_chart_date(params)
- if @report.template.blank?
- render text: "没有模板,请先添加report模板"
- else
- render @report.template
- end
- end
-
- def new
- @report = Report.new
- end
-
- def edit
- end
-
- def create
- @report = Report.new(report_params)
-
- respond_to do |format|
- if @report.save
- format.html { redirect_to reports_url, notice: '添加成功' }
- else
- format.html { render :new }
- end
- end
- end
-
- def update
- respond_to do |format|
- if @report.update(report_params)
- format.html { redirect_to reports_url, notice: '修改成功' }
- else
- format.html { render :edit }
- end
- end
- end
-
- def destroy
- @report.destroy
- respond_to do |format|
- format.html { redirect_to reports_url, notice: '删除成功' }
- end
- end
-
- private
- def set_report
- @report = Report.find(params[:id])
- end
-
- def report_params
- params.require(:report).permit(:name, :sql_code, :is_sql_category, :category_name, :connect_id, :template, :url)
- end
-end
+class ReportsController < ApplicationController
+ before_action :set_report, only: [:show, :edit, :update, :destroy]
+
+ def index
+ @reports = Report.all.page(params[:page]).per(50)
+ end
+
+ def show
+ @data = @report.report_date(params)
+ #@result = @report.get_chart_date(params)
+ if @report.template.blank?
+ render text: "没有模板,请先添加report模板"
+ else
+ render @report.template
+ end
+ end
+
+ def new
+ @report = Report.new
+ end
+
+ def edit
+ end
+
+ def create
+ @report = Report.new(report_params)
+
+ respond_to do |format|
+ if @report.save
+ format.html { redirect_to reports_url, notice: '添加成功' }
+ else
+ format.html { render :new }
+ end
+ end
+ end
+
+ def update
+ respond_to do |format|
+ if @report.update(report_params)
+ format.html { redirect_to reports_url, notice: '修改成功' }
+ else
+ format.html { render :edit }
+ end
+ end
+ end
+
+ def destroy
+ @report.destroy
+ respond_to do |format|
+ format.html { redirect_to reports_url, notice: '删除成功' }
+ end
+ end
+
+ private
+ def set_report
+ @report = Report.find(params[:id])
+ end
+
+ def report_params
+ params.require(:report).permit(:name, :sql_code, :is_sql_category, :category_name, :connect_id, :template, :url)
+ end
+end