clarion/app/controllers/public/personal_profiles_controlle...

41 lines
1.0 KiB
Ruby
Raw Normal View History

2015-08-15 03:43:41 +03:00
module Public
class PersonalProfilesController < Public::ApplicationController
2019-04-28 02:15:39 +03:00
before_action :authenticate_user!
2015-08-15 03:43:41 +03:00
def create
@profile = current_user.build_personal_profile(current_conference, profile_params)
if @profile.save
2015-08-15 10:04:03 +03:00
flash[:notice] = t('views.personal_profiles.successfully_created')
2015-08-15 03:43:41 +03:00
redirect_to root_path
else
render action: :new
end
end
def edit
@profile = current_user.find_or_build_personal_profile(current_conference)
2015-08-15 03:43:41 +03:00
end
def update
@profile = current_user.personal_profile(current_conference)
if @profile.update_attributes(profile_params)
2015-08-15 10:04:03 +03:00
flash[:notice] = t('views.personal_profiles.successfully_updated')
2015-08-15 03:43:41 +03:00
redirect_to root_path
else
render action: 'edit'
end
end
private
def profile_params
params.require(:personal_profile).permit(
:picture, :picture_cache, :first_name, :last_name, :public_email,
:organisation, :github, :twitter, :mobile_phone, :biography
)
end
end
end