Skip to content

Instantly share code, notes, and snippets.

@mzaragoza
Created September 25, 2013 12:00
Show Gist options
  • Save mzaragoza/6698662 to your computer and use it in GitHub Desktop.
Save mzaragoza/6698662 to your computer and use it in GitHub Desktop.
class UsersController < ApplicationController
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "You have successfully registered, please log in!"
redirect_to login_path
else
render :new
end
end
def edit
@user = current_user
end
def update
@user = User.find(params[:user][:id])
if @user.update(users_params)
flash[:notice] = "Thanks! your password has been updated."
redirect_to post_path(@post)
else
render :edit
end
end
private
def users_params
params.require(:user).permit(:username, :password)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment