Implement Callouts controller
This commit is contained in:
parent
0dab083702
commit
c4667f8703
2 changed files with 32 additions and 0 deletions
27
app/controllers/callouts_controller.rb
Normal file
27
app/controllers/callouts_controller.rb
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue