Sha256: 8e2302e6385caf1577bdafcfabc50bcb29f389c9d617de00810020bc02e7fc2c

Contents?: true

Size: 1.12 KB

Versions: 17

Compression:

Stored size: 1.12 KB

Contents

class Admin::UsersController < Admin::AdminController
  MODEL = self.controller_name.singularize.downcase.to_sym
  
  def index
    @users = User.paginate :page => params[:page], :per_page => Settings.page_limit
  end
  
  def show
    @user = User.find(params[:id])
  end
  
  def new
    @user = User.new
  end
  
  def create
    @user = User.new(params[MODEL])
    @user.role = params[MODEL][:role]
    if @user.save
      flash[:notice] = "Created #{@user.name}"
      redirect_to admin_user_url(@user)
    else
      render :action => 'new'
    end
  end
  
  def edit
    @user = User.find(params[:id])
  end
  
  def update
    @user = User.find(params[:id])
    @user.role = params[MODEL][:role]
    if @user.update_attributes(params[MODEL])
      flash[:notice] = "Updated #{@user.name}"
      redirect_to admin_user_url(@user)
    else
      render :action => 'edit'
    end
  end
  
  def destroy
    @user = User.find(params[:id])
    if @user != current_user
      @user.destroy
      flash[:notice] = "Deleted #{@user.name}"
    else
      flash[:error] = "Cannot delete yourself"
    end
    redirect_to admin_users_url
  end
    
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
headstart-0.11.2 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.11.1 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.9.2 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.9.1 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.9.0 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.8.0 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.7.0 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.6.2 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.6.1 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.6.0 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.5.5 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.5.4 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.5.3 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.5.2 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.5.1 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.5.0 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb
headstart-0.4.2 generators/headstart_admin/templates/app/controllers/admin/users_controller.rb