Sha256: 34f6352c5d29c6eed0187d65520b767dd4911b1ca63fcd219446f0a3f6b7476d

Contents?: true

Size: 1.49 KB

Versions: 1

Compression:

Stored size: 1.49 KB

Contents

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

    # GET /announcements
    def index
      @announcements = Announcement.all
    end

    # GET /announcements/1
    def show
    end

    # GET /announcements/new
    def new
      @announcement = Announcement.new
    end

    # GET /announcements/1/edit
    def edit
    end

    # POST /announcements
    def create
      @announcement = Announcement.new(announcement_params)

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

    # PATCH/PUT /announcements/1
    def update
      if @announcement.update(announcement_params)
        redirect_to @announcement, notice: "Announcement was successfully updated.", status: :see_other
      else
        render :edit, status: :unprocessable_entity
      end
    end

    # DELETE /announcements/1
    def destroy
      @announcement.destroy
      redirect_to announcements_url, notice: "Announcement was successfully destroyed.", status: :see_other
    end

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

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