Sha256: 03eec81f78cd77b0734fa0fa610ebb2576efbd286c30bacb2a45c9465b175fd9

Contents?: true

Size: 794 Bytes

Versions: 5

Compression:

Stored size: 794 Bytes

Contents

class UsersController < ApplicationController
  before_action :set_user

  def index
    @users = User.all
  end

  def show; end

  def new; end

  def create
    if @user.save
      flash[:notice] = t(".user_was_created")
      redirect_to user_path(@user)
    else
      flash[:error] = @user.errors.full_messages.join(". ")
      render :new
    end
  end

  def edit; end

  def update
    if @user.update_attributes(user_params)
      flash[:notice] = controller_t(".user_was_updated")
      redirect_to user_path(@user)
    else
      flash[:error] = @user.errors.full_messages.join(". ")
      render :edit
    end
  end

private

  def set_user
    @user = User.find(params[:id].to_i) if params[:id].to_i > 0
  end

  def user_params
    params.require(:user).permit(:email)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
awesome_translations-0.0.58 spec/dummy/app/controllers/users_controller.rb
awesome_translations-0.0.57 spec/dummy/app/controllers/users_controller.rb
awesome_translations-0.0.56 spec/dummy/app/controllers/users_controller.rb
awesome_translations-0.0.55 spec/dummy/app/controllers/users_controller.rb
awesome_translations-0.0.54 spec/dummy/app/controllers/users_controller.rb