diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-02-05 16:48:28 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-02-05 16:48:28 +0300 |
commit | 5976410be2ea26ac5aa2e418a32f3105bf29e523 (patch) | |
tree | 6038d1bfd0c81a159dd9ba21c095db355e010f7d /app | |
parent | a85b85e1d8e6a482af7d13477068e6ab976c4b25 (diff) |
Refactor UserCalloutsController enum check
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/user_callouts_controller.rb | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/app/controllers/user_callouts_controller.rb b/app/controllers/user_callouts_controller.rb index aa048a9a1fc..18cde4a7b1a 100644 --- a/app/controllers/user_callouts_controller.rb +++ b/app/controllers/user_callouts_controller.rb @@ -1,6 +1,6 @@ class UserCalloutsController < ApplicationController def create - if check_feature_name && ensure_callout + if ensure_callout.persisted? respond_to do |format| format.json { head :ok } end @@ -13,15 +13,11 @@ class UserCalloutsController < ApplicationController private - def check_feature_name - UserCallout.feature_names.keys.include?(callout_param) - end - def ensure_callout - current_user.callouts.find_or_create_by(feature_name: callout_param) + current_user.callouts.find_or_create_by(feature_name: UserCallout.feature_names[feature_name]) end - def callout_param + def feature_name params.require(:feature_name) end end |