Sha256: 5911535516122f1747f375ec1aa2245c47f01620df5de44f8908a76e1a99060a

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

class FunctionsController < ApplicationController
  before_action :set_function, only: [:edit, :update, :destroy, :setting_routes, :setting_handle]

  def index
    @functions = Function.all
  end

  def new
    @function = Function.new
  end

  def create
    @function = Function.new(function_params)
    respond_to do |format|
      if @function.save
        format.html{ redirect_to functions_path }
      else
        format.html{ render :new }
      end
    end
  end

  def edit
  end

  def update
    respond_to do |format|
      if @function.update(function_params)
        format.html{ redirect_to functions_path }
      else
        format.html{ render :edit }
      end
    end
  end

  def destroy
    respond_to do |format|
      @function.destroy
      format.html{ redirect_to functions_path }
    end
  end

  def setting_routes
    @routes = Routepath.order(:controller)
    @funcRoutes = @function.routepaths
  end

  def setting_handle
    @function.routepaths.update_all(function_id: nil)
    Routepath.where(id: params[:routepath_id]).update_all(function_id: @function.id)
    respond_to do |format|
      format.html{ redirect_to functions_path }
    end
  end

  private
  def set_function
    @function = Function.find params[:id]
  end

  def function_params
    params.require(:function).permit(:name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
admin-sys-1.1.0 app/controllers/functions_controller.rb