Sha256: d0363953a824ec6f5c25e011278065d557fd0be9f4047df3923621c0fb9732c4

Contents?: true

Size: 1.13 KB

Versions: 9

Compression:

Stored size: 1.13 KB

Contents

module Georgia
  class UsersController < ApplicationController

    load_and_authorize_resource class: Georgia::User

    def index
      @users = User.order(:created_at).page(params[:page])
    end

    def show
      redirect_to edit_user_path(params[:id])
    end

    def new
      @user = User.new
    end

    def edit
      @user = User.find(params[:id])
    end

    def create
      @user = User.new(params[:user])

      if @user.save
        redirect_to users_url, notice: "User was successfully created."
      else
        render 'new'
      end
    end

    def update
      @user = User.find(params[:id])
      params[:user].delete(:password) if params[:user][:password].blank?
      params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
      if @user.update_attributes(params[:user])
        redirect_to users_url, notice: "User was successfully updated."
      else
        render 'edit'
      end
    end

    def destroy
      @user = User.find(params[:id])
      @user.destroy
      redirect_to users_url, notice: "User was successfully deleted."
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
georgia-0.7.8 app/controllers/georgia/users_controller.rb
georgia-0.7.7 app/controllers/georgia/users_controller.rb
georgia-0.7.6 app/controllers/georgia/users_controller.rb
georgia-0.7.5 app/controllers/georgia/users_controller.rb
georgia-0.7.4 app/controllers/georgia/users_controller.rb
georgia-0.7.3 app/controllers/georgia/users_controller.rb
georgia-0.7.2 app/controllers/georgia/users_controller.rb
georgia-0.7.1 app/controllers/georgia/users_controller.rb
georgia-0.7.0 app/controllers/georgia/users_controller.rb