Sha256: 9156ae246debb6ff0deabf81e2b655637654e6fa07ffa9fe454aa4c1b3b3c122

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 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

3 entries across 3 versions & 1 rubygems

Version Path
admin-sys-1.0.2 app/controllers/functions_controller.rb
admin-sys-1.0.1 app/controllers/functions_controller.rb
admin-sys-1.0.0 app/controllers/functions_controller.rb