48 lines
841 B
Ruby
48 lines
841 B
Ruby
class Admin::UsersController < Admin::ApplicationController
|
|
|
|
def index
|
|
@users = User.find(:all)
|
|
end
|
|
|
|
def show
|
|
@user = User.find(params[:id])
|
|
end
|
|
|
|
def new
|
|
@user = User.new
|
|
end
|
|
|
|
def create
|
|
@user = User.new(params[:user])
|
|
if @user.save
|
|
flash[:notice] = "Account registered!"
|
|
redirect_to [:admin, @user]
|
|
else
|
|
render :action => :new
|
|
end
|
|
end
|
|
|
|
def edit
|
|
@user = User.find(params[:id])
|
|
end
|
|
|
|
def update
|
|
@user = User.find(params[:id])
|
|
if @user.update_attributes(params[:user])
|
|
flash[:notice] = "Account updated!"
|
|
redirect_to [:admin, @user]
|
|
else
|
|
render :action => :edit
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
@user = User.find(params[:id])
|
|
if @user.destroy
|
|
redirect_to admin_users_path
|
|
else
|
|
redirect_to @user
|
|
end
|
|
end
|
|
end
|