Created
September 25, 2013 12:00
-
-
Save mzaragoza/6698662 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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