[logaling-commit] logaling/logaling-server [prioritize-the-search] Extract #reset_of_user_config?

アーカイブの一覧に戻る

SHIMADA Koji null+****@clear*****
Tue Sep 25 20:07:12 JST 2012


SHIMADA Koji	2012-09-25 20:07:12 +0900 (Tue, 25 Sep 2012)

  New Revision: 8f8784b2d26fde44667268690efd611ea01a88aa
  https://github.com/logaling/logaling-server/commit/8f8784b2d26fde44667268690efd611ea01a88aa

  Log:
    Extract #reset_of_user_config?

  Modified files:
    app/controllers/user_configs_controller.rb

  Modified: app/controllers/user_configs_controller.rb (+11 -6)
===================================================================
--- app/controllers/user_configs_controller.rb    2012-09-25 19:41:59 +0900 (ee1c52c)
+++ app/controllers/user_configs_controller.rb    2012-09-25 20:07:12 +0900 (bc93bd5)
@@ -12,15 +12,20 @@ class UserConfigsController < ApplicationController
 
   def update
     user_config = UserConfig.find(params[:id])
-    if user_config.glossary_name == params[:user_config][:glossary_name] &&
-      user_config.source_language == params[:user_config][:source_language] &&
-      user_config.target_language == params[:user_config][:target_language]
+    if reset_of_user_config?(user_config, params[:user_config])
       user_config.destroy
-      redirect_to dashboard_path, notice: 'User config was successfully unset.'
-    elsif user_config.update_attributes!(params[:user_config])
-      redirect_to dashboard_path, notice: 'User config was successfully update.'
+    else
+      user_config.update_attributes!(params[:user_config])
     end
+    redirect_to dashboard_path, notice: 'User config was successfully update.'
   rescue => e
     redirect_to dashboard_path, notice: 'User config setting was failed.'
   end
+
+  private
+  def reset_of_user_config?(current_user_config, submitted_config_data)
+    current_user_config.glossary_name == submitted_config_data[:glossary_name] &&
+    current_user_config.source_language == submitted_config_data[:source_language] &&
+    current_user_config.target_language == submitted_config_data[:target_language]
+  end
 end
-------------- next part --------------
An HTML attachment was scrubbed...
ダウンロード 



More information about the logaling-commit mailing list
アーカイブの一覧に戻る