al13ntown/app/controllers/miniblogs_controller.rb

54 lines
1.1 KiB
Ruby
Raw Normal View History

2026-08-24 20:12:41 +00:00
class MiniblogsController < ApplicationController
allow_unauthenticated_access(only: %i[index show])
def index
@miniblog = Miniblog.all
end
def edit
@miniblog = Miniblog.find(params[:id])
end
def update
@miniblog = Miniblog.find(params[:id])
if @miniblog.update(scrap_params)
redirect_to posts_path, notice: "scrap edited."
else
render :edit, status: :unprocessable_entity, notice: "U fucked up somewhere."
end
end
def new
@miniblog = Miniblog.new
end
def create
@miniblog = Miniblog.new(miniblog_params)
if @miniblog.save
redirect_to miniblog_path, notice: "scrap created."
else
render :new, status: :unprocessable_entity, notice: "U fucked up somewhere."
end
end
def destroy
@miniblog = Miniblog.find(params[:id])
@miniblog.destroy
redirect_to welcome_index_path, notice: "Member deleted."
end
def show
@miniblog = Miniblog.find_by(id: params[:id])
if @miniblog.nil?
flash[:alert] = "Miniblog entry not found"
redirect_to welcome_index_path
return
end
end
private
def miniblog_params
params.require(:scrap).permit(:text, :music, :mood)
end
end