Sha256: dbf64d1b50c00a1f18d478b4827efc90540c2675983bd7deaaed1327d9724ad3

Contents?: true

Size: 1.27 KB

Versions: 9

Compression:

Stored size: 1.27 KB

Contents

# -*- encoding: utf-8 -*-
# -*- frozen_string_literal: true -*-
# -*- warn_indent: true -*-

class UsersController < ApplicationController

  before_action :find_user, except: [:index, :new, :create]

  def index
    @users = ::User.all
  end

  def new
    @user = ::User.new
  end

  def create
    @user = ::User.new(user_params)
    if @user.save
      redirect_to users_path
    else
      render :new, status: :unprocessable_entity
    end
  end

  def edit
  end

  def update
    if @user.update(user_params)
      redirect_to users_path
    else
      render :edit, status: :unprocessable_entity
    end
  end

  def destroy
    @user.destroy
    redirect_to users_path
  end

  private

  def user_params
    params.require(:user).permit(
      :name,
      :email,
      :password,
      :mobile_number,
      :birth_date,
      :terms,
      :excellence,
      :blog_url,
      :fruit_id,
      :favorite_color,
      :username,
      :expected_ctc,
      :interview_date,
      :interview_time,
      :interview_datetime,
      :weekly_off,
      :gender,
      skill_ids: [],
      address_attributes: [
        :street,
        :state,
        :city,
        :postal_code,
        :country_id,
      ]
    )
  end

  def find_user
    @user = ::User.find(params.fetch(:id))
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rails_bootstrap_form-0.9.5 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.9.4 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.9.3 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.9.2 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.9.1 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.9.0 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.8.3 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.8.2 demo/app/controllers/users_controller.rb
rails_bootstrap_form-0.8.1 demo/app/controllers/users_controller.rb