Sha256: 7e3e2b6df8df9fabf843e30118c7baac5a10f08676cb4859e058d3067e9f0584

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

class Shoppe::UsersController < Shoppe::ApplicationController
  
  before_filter { @active_nav = :users }
  before_filter { params[:id] && @user = Shoppe::User.find(params[:id]) }
  
  def index
    @users = Shoppe::User.all
  end
  
  def new
    @user = Shoppe::User.new
  end
  
  def create
    @user = Shoppe::User.new(safe_params)
    if @user.save
      redirect_to :users, :flash => {:notice => "User has been created successfully"}
    else
      render :action => "new"
    end
  end
  
  def edit
  end
  
  def update
    if @user.update(safe_params)
      redirect_to [:edit, @user], :flash => {:notice => "User has been updated successfully"}
    else
      render :action => "edit"
    end
  end
  
  def destroy
    raise Shoppe::Error, "You cannot remove yourself" if @user == current_user
    @user.destroy
    redirect_to :users, :flash => {:notice => "User has been removed successfully"}
  end
  
  private
  
  def safe_params
    params[:user].permit(:first_name, :last_name, :email_address, :password, :password_confirmation)
  end
  
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
shoppe-0.0.14 app/controllers/shoppe/users_controller.rb
shoppe-0.0.13 app/controllers/shoppe/users_controller.rb
shoppe-0.0.12 app/controllers/shoppe/users_controller.rb
shoppe-0.0.11 app/controllers/shoppe/users_controller.rb
shoppe-0.0.10 app/controllers/shoppe/users_controller.rb
shoppe-0.0.9 app/controllers/shoppe/users_controller.rb
shoppe-0.0.8 app/controllers/shoppe/users_controller.rb
shoppe-0.0.7 app/controllers/shoppe/users_controller.rb
shoppe-0.0.6 app/controllers/shoppe/users_controller.rb
shoppe-0.0.5 app/controllers/shoppe/users_controller.rb