56 lines
1.2 KiB
Ruby
56 lines
1.2 KiB
Ruby
class MembersController < ApplicationController
|
|
before_action :set_member, only: %i[ show edit update destroy]
|
|
|
|
def index
|
|
@members = Member.page params[:page]
|
|
end
|
|
|
|
def show
|
|
authorize @member
|
|
render "settings"
|
|
end
|
|
|
|
def edit
|
|
authorize @member
|
|
end
|
|
|
|
def settings
|
|
@member = current_member
|
|
end
|
|
|
|
def create
|
|
@member = Member.new(member_params)
|
|
|
|
if @member.save
|
|
redirect_to @member, notice: "Member was successfully created."
|
|
else
|
|
render :new, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def update
|
|
authorize @member
|
|
if @member.update(member_params)
|
|
redirect_to @member, notice: "Member was successfully updated."
|
|
else
|
|
render :edit, status: :unprocessable_entity
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@member.destroy
|
|
redirect_to members_url, notice: "Member was successfully destroyed."
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_member
|
|
@member = Member.find(params[:id])
|
|
end
|
|
|
|
# Only allow a list of trusted parameters through.
|
|
def member_params
|
|
params.require(:member).permit(:name, :public, :bio , :picture)
|
|
end
|
|
end
|