Files
growstuff/app/controllers/forums_controller.rb
Daniel O'Connor ed87d23ece Merge pull request #4560 from Growstuff/fix-i18n-locale-texts-16171345716630423189
Fix Rails/I18nLocaleTexts RuboCop errors
2026-04-26 13:36:10 +09:30

60 lines
1.1 KiB
Ruby

# frozen_string_literal: true
class ForumsController < ApplicationController
load_and_authorize_resource
respond_to :html, :json
responders :flash
# GET /forums
# GET /forums.json
def index
@forums = Forum.all.order(:name)
respond_with(@forums)
end
# GET /forums/1
# GET /forums/1.json
def show
respond_with(@forum)
end
# GET /forums/new
# GET /forums/new.json
def new
@forum = Forum.new
respond_with(@forum)
end
# GET /forums/1/edit
def edit; end
# POST /forums
# POST /forums.json
def create
@forum = Forum.new(forum_params)
flash[:notice] = t('forums.created') if @forum.save
respond_with(@forum)
end
# PUT /forums/1
# PUT /forums/1.json
def update
flash[:notice] = t('forums.updated') if @forum.update(forum_params)
respond_with(@forum)
end
# DELETE /forums/1
# DELETE /forums/1.json
def destroy
@forum.destroy
flash[:notice] = t('forums.deleted')
redirect_to forums_url
end
private
def forum_params
params.require(:forum).permit(:description, :name, :owner_id, :slug)
end
end