Sha256: c79f00a0bd1e49b932e3f4f77aa03c727e0cc831f15fd47bcb8cd0ee9247c205

Contents?: true

Size: 986 Bytes

Versions: 3

Compression:

Stored size: 986 Bytes

Contents

class Admin::UsersController < Admin::BaseController

  def index
    list
    render :action => 'list'
  end

  def list
    @users = User.find :all
  end

  def show
    @user = User.find(params[:id], :include => [ :articles ])
    @articles = @user.articles
  end

  def new
    @user = User.new(params[:user])
    setup_profiles
    if request.post? and @user.save
      flash[:notice] = 'User was successfully created.'
      redirect_to :action => 'list'
    end
  end

  def edit
    @user = User.find_by_id(params[:id])
    setup_profiles
    @user.attributes = params[:user]
    if request.post? and @user.save
      flash[:notice] = 'User was successfully updated.'
      redirect_to :action => 'show', :id => @user.id
    end
  end

  def destroy
    @user = User.find(params[:id])
    if request.post?
      @user.destroy if User.count > 1
      redirect_to :action => 'list'
    end
  end

  def setup_profiles
    @profiles = Profile.find(:all, :order => 'id')
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
typo-5.0.1 app/controllers/admin/users_controller.rb
typo-5.0.2 app/controllers/admin/users_controller.rb
typo-5.0 app/controllers/admin/users_controller.rb