diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-01-27 00:13:54 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-01-27 01:24:26 +0300 |
commit | c4667f87037150a408da5c133e573714807e17b3 (patch) | |
tree | f23d797d22f450d2f0e08acafa504dde945a2da4 | |
parent | 0dab083702ff4364bc25ea29812a4305c58e5a4f (diff) |
Implement Callouts controller
-rw-r--r-- | app/controllers/callouts_controller.rb | 27 | ||||
-rw-r--r-- | config/routes.rb | 5 |
2 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/callouts_controller.rb b/app/controllers/callouts_controller.rb new file mode 100644 index 00000000000..a7bccfcce78 --- /dev/null +++ b/app/controllers/callouts_controller.rb @@ -0,0 +1,27 @@ +class CalloutsController < ApplicationController + before_action :callout, only: [:dismiss] + + def dismiss + respond_to do |format| + format.json do + if @callout + @callout.update(dismissed_state: true) + else + Callout.create(feature_name: callout_param, dismissed_state: true, user: current_user) + end + + head :ok + end + end + end + + private + + def callout + @callout = Callout.find_by(user: current_user, feature_name: callout_param) + end + + def callout_param + params.require(:feature_name) + end +end diff --git a/config/routes.rb b/config/routes.rb index f162043dd5e..f768bcebc7e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -90,6 +90,11 @@ Rails.application.routes.draw do # Notification settings resources :notification_settings, only: [:create, :update] + # Callouts + namespace :callouts do + post :dismiss + end + draw :google_api draw :import draw :uploads |