Sha256: e1b680de8c27280243a9b35486a74358a5438098d9568746cfb4d169d29d873b
Contents?: true
Size: 1.51 KB
Versions: 4
Compression:
Stored size: 1.51 KB
Contents
module Hatchy class Admin::AnnouncementsController < Admin::ApplicationController before_action :set_announcement, only: [:edit, :show, :update, :destroy] # GET /announcements def index @announcements = Hatchy::Announcement.order(:created_at) end # GET /announcement/new def new @announcement = Hatchy::Announcement.new end # GET /announcement/:id/edit def edit end # GET /announcement/:id def show end # POST /announcement def create @announcement = Hatchy::Announcement.new(announcement_params) if @announcement.valid? @announcement.save redirect_to admin_announcement_path(@announcement), notice: "Announcement saved successfully" else render :new end end # PATCH /announcement/:id # PUT /announcement/:id def update if @announcement.update(announcement_params) redirect_to admin_announcement_path(@announcement), notice: 'Announcement was successfully updated.' else render :edit flash[:error] = @announcement.errors.full_messages.to_sentence end end # DELETE /announcement/1 def destroy @announcement.destroy redirect_to admin_announcements_path, notice: 'Announcement was successfully destroyed.' end private def set_announcement @announcement = Hatchy::Announcement.find(params[:id]) end def announcement_params params[:announcement].permit(:message, :starts_at, :ends_at) end end end
Version data entries
4 entries across 4 versions & 1 rubygems