Commit c280fafa authored by Matija Čupić's avatar Matija Čupić

Refactor UserCalloutsController enum check

parent f0420691
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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment