2018-02-02 16:51:03 -05:00
|
|
|
class UserCalloutsController < ApplicationController
|
2018-02-02 16:23:26 -05:00
|
|
|
def create
|
2018-02-05 08:48:28 -05:00
|
|
|
if ensure_callout.persisted?
|
2018-02-02 16:23:26 -05:00
|
|
|
respond_to do |format|
|
|
|
|
format.json { head :ok }
|
|
|
|
end
|
2018-02-01 21:07:33 -05:00
|
|
|
else
|
2018-02-02 16:23:26 -05:00
|
|
|
respond_to do |format|
|
|
|
|
format.json { head :bad_request }
|
|
|
|
end
|
2018-01-26 16:13:54 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-02-01 21:07:33 -05:00
|
|
|
def ensure_callout
|
2018-02-05 08:48:28 -05:00
|
|
|
current_user.callouts.find_or_create_by(feature_name: UserCallout.feature_names[feature_name])
|
2018-01-26 16:13:54 -05:00
|
|
|
end
|
|
|
|
|
2018-02-05 08:48:28 -05:00
|
|
|
def feature_name
|
2018-01-26 16:13:54 -05:00
|
|
|
params.require(:feature_name)
|
|
|
|
end
|
|
|
|
end
|