class UsersController < ApplicationController before_action :require_user, :only => [:show, :edit, :update] def new @user = User.new end def create @user = User.new(params[:user]) # Saving without session maintenance to skip # auto-login which can't happen here because # the User has not yet been activated if @user.save flash[:notice] = "Your account has been created." redirect_to signup_url else flash[:notice] = "There was a problem creating you." render :action => :new end end def show @user = current_user end def edit @user = current_user end def update @user = current_user # makes our views "cleaner" and more consistent if @user.update_attributes(params[:user]) flash[:notice] = "Account updated!" redirect_to account_url else render :action => :edit end end end