Class: Bbs::ProfilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/bbs/profiles_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#logged_in?

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
# File 'app/controllers/bbs/profiles_controller.rb', line 9

def create
  if current_user.create_profile(profile_params)
    redirect_to edit_profile_path, notice: t('.success')
  else
    flash.now[:alert] = current_user.profile.errors.full_messages

    render :edit
  end
end

#editObject



5
6
7
# File 'app/controllers/bbs/profiles_controller.rb', line 5

def edit
  current_user.build_profile unless current_user.profile
end

#updateObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/bbs/profiles_controller.rb', line 19

def update
  if current_user.profile.update(profile_params)
    redirect_to edit_profile_path, notice: t('.success')
  else
    flash.now[:alert] = current_user.profile.errors.full_messages

    render :edit
  end
end