sarting to generalize profiles

This commit is contained in:
2023-01-16 00:17:22 +02:00
parent 485c0475b7
commit 4ffc6e3c85
26 changed files with 165 additions and 207 deletions

View File

@ -0,0 +1,62 @@
class ProfilesController < ApplicationController
before_action :set_profile, only: %i[ show edit update destroy ]
# GET /profiles
def index
@profiles = Profile.page params[:page]
end
# GET /profiles/1
def show
end
# GET /profiles/new
def new
@profile = Profile.new
end
# GET /profiles/1/edit
def edit
authorize @profile
end
# POST /profiles
def create
@profile = Profile.new(profile_params)
@profile.member = current_member
if @profile.save
redirect_to @profile, notice: "Successfully created Profile profile"
else
render :new, status: :unprocessable_entity
end
end
# PATCH/PUT /profiles/1
def update
authorize @profile
if @profile.update(profile_params)
redirect_to @profile, notice: "Profile Profile was updated."
else
render :edit, status: :unprocessable_entity
end
end
# DELETE /profiles/1
def destroy
authorize @profile
@profile.destroy
redirect_to profiles_url, notice: "Profile was successfully destroyed."
end
private
# Use callbacks to share common setup or constraints between actions.
def set_profile
@profile = Profile.find(params[:id])
end
# Only allow a list of trusted parameters through.
def profile_params
params.require(:profile).permit(:name, :bio, :picture)
end
end