Sha256: 3ffd1ad6c2c575ab1182d04a66503d942095d1d2d5b9110875488ea467beb822

Contents?: true

Size: 1.62 KB

Versions: 1

Compression:

Stored size: 1.62 KB

Contents

module LesliBell
    class NotificationsController < ApplicationController
        before_action :set_notification, only: %i[ show edit update destroy ]

        # GET /notifications
        def index
        @notifications = Notification.all
        end

        # GET /notifications/1
        def show
        end

        # GET /notifications/new
        def new
        @notification = Notification.new
        end

        # GET /notifications/1/edit
        def edit
        end

        # POST /notifications
        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

        # PATCH/PUT /notifications/1
        def update
        if @notification.update(notification_params)
        redirect_to @notification, notice: "Notification was successfully updated.", status: :see_other
        else
        render :edit, status: :unprocessable_entity
        end
        end

        # DELETE /notifications/1
        def destroy
        @notification.destroy
        redirect_to notifications_url, notice: "Notification was successfully destroyed.", status: :see_other
        end

        private
        # Use callbacks to share common setup or constraints between actions.
        def set_notification
        @notification = Notification.find(params[:id])
        end

        # Only allow a list of trusted parameters through.
        def notification_params
        params.fetch(:notification, {})
        end
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lesli_bell-0.1.0 app/controllers/lesli_bell/notifications_controller.rb