Sha256: 293137e9257d80052f641996ddbb025093f3fe21a39cff1ddab3a6d423d21219

Contents?: true

Size: 757 Bytes

Versions: 2

Compression:

Stored size: 757 Bytes

Contents

class UsersController < ApplicationController
  before_filter :find_resource, only: [:edit, :update, :destroy]
  
  respond_to :html
  
  before_filter :authenticate_user!
  
  def index
    @users = User.order('name ASC')
  end
  
  def edit
  end
  
  def update
    if params[:user][:password].present? ? @user.update_attributes(params[:user]) : @user.update_without_password(params[:user])
      redirect_to edit_user_path(current_user), notice: t('general.form.successfully_updated')
    else
      render :edit
    end
  end

  def destroy
    @user.destroy
    redirect_to users_url, notice: t('general.form.destroyed')
  end
  
  def resource
    @user
  end
  
  private
  
  def find_resource
    @user = User.friendly.find(params[:id])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
home_page-0.0.5 app/controllers/users_controller.rb
home_page-0.0.4 app/controllers/users_controller.rb