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