Class: LesliBell::NotificationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/lesli_bell/notifications_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /notifications



23
24
25
26
27
28
29
30
31
# File 'app/controllers/lesli_bell/notifications_controller.rb', line 23

def create
@notification = Notification.new(notification_params)

if @notification.save
redirect_to @notification, notice: "Notification was successfully created."
else
render :new, status: :unprocessable_entity
end
end

#destroyObject

DELETE /notifications/1



41
42
43
44
# File 'app/controllers/lesli_bell/notifications_controller.rb', line 41

def destroy
@notification.destroy
redirect_to notifications_url, notice: "Notification was successfully destroyed.", status: :see_other
end

#editObject

GET /notifications/1/edit



19
20
# File 'app/controllers/lesli_bell/notifications_controller.rb', line 19

def edit
end

#indexObject

GET /notifications



6
7
8
# File 'app/controllers/lesli_bell/notifications_controller.rb', line 6

def index
    @notifications = respond_as_pagination(NotificationService.new(current_user, query).index)
end

#newObject

GET /notifications/new



15
16
# File 'app/controllers/lesli_bell/notifications_controller.rb', line 15

def new
end

#showObject

GET /notifications/1



11
12
# File 'app/controllers/lesli_bell/notifications_controller.rb', line 11

def show
end

#updateObject

PATCH/PUT /notifications/1



34
35
36
37
38
# File 'app/controllers/lesli_bell/notifications_controller.rb', line 34

def update
    NotificationService.new(current_user).read(params[:id])
    @notifications = respond_as_pagination(NotificationService.new(current_user, query).index)
    render :index
end