app/controllers/functions_controller.rb in admin-sys-1.0.2 vs app/controllers/functions_controller.rb in admin-sys-1.1.0
- old
+ new
@@ -1,64 +1,64 @@
-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
+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