Sha256: fc21c834c2819bf72e7f6be5192120968d32a005bd38fa750973566d84cda3d0

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

class UsersController < ApplicationController
  before_filter :find_resource, only: [:edit, :update, :destroy]
  
  respond_to :html
  
  helper_method :resource
  
  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

1 entries across 1 versions & 1 rubygems

Version Path
home_page-0.0.3 app/controllers/users_controller.rb