Implement Callouts controller

This commit is contained in:
Matija Čupić 2018-01-26 22:13:54 +01:00
parent 0dab083702
commit c4667f8703
No known key found for this signature in database
GPG key ID: 4BAF84FFACD2E5DE
2 changed files with 32 additions and 0 deletions

View 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

View file

@ -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