Sha256: 7dce8ac9856db66b71383de6ff9e64231e20abe2ed16774a12b6205883146041

Contents?: true

Size: 1.21 KB

Versions: 3

Compression:

Stored size: 1.21 KB

Contents

# encoding: UTF-8
class UserProfilesController < ApplicationController
  before_action :profile_controller
  before_action :set_user_profile, only: [:show, :edit, :update, :destroy]
  add_breadcrumb I18n.t('activerecord.models.user_profiles'), :user_profile_path

  def show
    add_breadcrumb @user_profile.first_name, user_profile_path
    respond_with(@user_profile)
  end

  def new
    add_breadcrumb t('tooltips.new'), new_user_profile_path
    @user_profile = current_user.build_user_profile
    respond_with(@user_profile)
  end

  def edit
    add_breadcrumb t('tooltips.edit'), edit_user_profile_path
  end

  def create
    @user_profile = current_user.build_user_profile(user_profile_params)
    @user_profile.save
    respond_with(@user_profile, location: user_profile_path)
  end

  def update
    @user_profile.update(user_profile_params)
    respond_with(@user_profile, location: user_profile_path)
  end

  private

  def profile_controller
    if current_user.user_profile.nil?
      redirect_to new_user_profile_path
    end
  end

  def set_user_profile
    @user_profile = current_user.user_profile
  end

  def user_profile_params
    params.require(:user_profile).permit(:first_name, :gsm, :last_name)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cybele-1.6.0 templates/app/controllers/user_profiles_controller.rb
cybele-1.5.1 templates/app/controllers/user_profiles_controller.rb
cybele-1.5.0 templates/app/controllers/user_profiles_controller.rb