Sha256: 9552afbf35bde0b455d272c301c55164be531eb6d6872593b7f197921fe60b57

Contents?: true

Size: 1.26 KB

Versions: 1

Compression:

Stored size: 1.26 KB

Contents

class SeriesController < ApplicationController
  before_action :set_report
  before_action :set_series, only: [:show, :edit, :update, :destroy]

  def index
    @series = @report.series.page(params[:page]).per(50)
  end

  def show
  end

  def new
    @series = Series.new
  end

  def edit
  end

  def create
    @series = Series.new(series_params)
    @series.report = @report
    respond_to do |format|
      if @series.save
        format.html { redirect_to report_series_index_url, notice: '添加成功' }
      else
        format.html { render :new }
      end
    end
  end

  def update
    respond_to do |format|
      if @series.update(series_params)
        format.html { redirect_to report_series_index_url, notice: '修改成功' }
      else
        format.html { render :edit }
      end
    end
  end

  def destroy
    @series.destroy
    respond_to do |format|
      format.html { redirect_to report_series_index_url, notice: '删除成功' }
    end
  end

  private
    def set_series
      @series = Series.find(params[:id])
    end

    def set_report
      @report = Report.find(params[:report_id])
    end

    def series_params
      params.require(:series).permit(:report_id, :name, :sql_key)
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
admin-sys-1.1.0 plugins/report/app/controllers/series_controller.rb