Sha256: ba84e7ebcb891ec514d0439c97a41dc7a89a3d1b1e471931080ecd82e3dcd5ed

Contents?: true

Size: 769 Bytes

Versions: 2

Compression:

Stored size: 769 Bytes

Contents

class UsersController < SbController
  
  protect_from_forgery
  
  before_filter :find_user, :only => [:show, :edit, :update, :destroy]
  before_filter :require_no_user, :only => [:new, :create]
  before_filter :require_user, :only => [:show, :edit, :update]

  def new
    @user = User.new
  end

  def create
    @user = User.new(params[:user])
    if @user.save!
      flash[:notice] = "Account registered!"
      redirect_back_or_default root_url
    else
      render :action => :new
    end
  end

  def update
    if @user.update_attributes(params[:user])
      flash[:notice] = "Account updated!"
      redirect_to root_url
    else
      render :action => :edit
    end
  end
  
  private
    def find_user
      @user = User.find(params[:id])
    end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
santey_blog-0.2.1 app/controllers/users_controller.rb
santey_blog-0.2.0 app/controllers/users_controller.rb