Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
47 lines (36 sloc) 887 Bytes
class ProfilesController < ApplicationController
def show
@user = User.find(params[:user_id])
@profile = @user.profile
end
def new
@user = User.find(params[:user_id])
@profile = @user.build_profile
end
def create
@user = User.find(params[:user_id])
@profile = @user.create_profile(profile_params)
if @profile.save
redirect_to user_profile_path(@profile)
else
render action: "new"
end
end
def edit
@user = User.find(params[:user_id])
@profile = @user.profile
end
def update
@user = User.find(params[:user_id])
@profile = @user.profile
if @profile.update(profile_params)
redirect_to user_profile_path(@user)
else
render 'edit'
end
end
private
def profile_params
params.require(:profile).permit(:description,:name, :last_name, :user_id)
end
end
You can’t perform that action at this time.