fix profile generation
This commit is contained in:
@ -12,7 +12,9 @@ class ProfilesController < ApplicationController
|
||||
|
||||
# GET /profiles/new
|
||||
def new
|
||||
@profile = Profile.new
|
||||
kind = params[:kind]
|
||||
kind = Profile.types.first unless Profile.types.include?(kind)
|
||||
@profile = Profile.new kind: kind
|
||||
end
|
||||
|
||||
# GET /profiles/1/edit
|
||||
@ -26,7 +28,7 @@ class ProfilesController < ApplicationController
|
||||
@profile.member = current_member
|
||||
|
||||
if @profile.save
|
||||
redirect_to @profile, notice: "Successfully created Profile profile"
|
||||
redirect_to member_path(current_member), notice: "Successfully created #{@profile.Kind} profile"
|
||||
else
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
@ -36,7 +38,7 @@ class ProfilesController < ApplicationController
|
||||
def update
|
||||
authorize @profile
|
||||
if @profile.update(profile_params)
|
||||
redirect_to @profile, notice: "Profile Profile was updated."
|
||||
redirect_to member_path(current_member), notice: "#{@profile.Kind} profile was updated."
|
||||
else
|
||||
render :edit, status: :unprocessable_entity
|
||||
end
|
||||
@ -46,7 +48,7 @@ class ProfilesController < ApplicationController
|
||||
def destroy
|
||||
authorize @profile
|
||||
@profile.destroy
|
||||
redirect_to profiles_url, notice: "Profile was successfully destroyed."
|
||||
redirect_to member_path(current_member), notice: "#{@profile.Kind} profile was successfully destroyed."
|
||||
end
|
||||
|
||||
private
|
||||
@ -57,6 +59,6 @@ class ProfilesController < ApplicationController
|
||||
|
||||
# Only allow a list of trusted parameters through.
|
||||
def profile_params
|
||||
params.require(:profile).permit(:name, :bio, :picture)
|
||||
params.require(:profile).permit(:name, :bio, :picture, :kind)
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user