From e6b2993ad072d0cad2e52997c7957aae0a03415c Mon Sep 17 00:00:00 2001 From: DavisLWebb Date: Sun, 2 Mar 2014 20:06:40 -0500 Subject: I changed the user controller --- app/controllers/sessions_controller.rb | 8 ++------ app/controllers/users_controller.rb | 9 ++++++++- app/models/user.rb | 1 + app/views/users/new.html.erb | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 8a9de56..722b8c2 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -7,19 +7,15 @@ class SessionsController < ApplicationController user = User.find_by(email: params[:session][:email].downcase) if user && user.authenticate(params[:session][:password]) sign_in user - #redirect goes here + redirect_to root_path else render 'new' end end def destroy - sign_out - - #I dont know where to redirect to so yeah - # redirect_to sign_in - + redirect_to root_path end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 74ab72c..2abc93e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,13 +1,14 @@ class UsersController < ApplicationController def new + @user = User.new end def create @user = User.new(user_params) if @user.save sign_in @user - #redirect_to @user + #redirect_to root_path else render 'new' end @@ -16,4 +17,10 @@ class UsersController < ApplicationController def show @user = User.find(param[:id]) end + + private + + def user_params + params.require(:user).permit(:name, :email, :user_name, :password, :password_confirmation) + end end diff --git a/app/models/user.rb b/app/models/user.rb index 6765822..f302baf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -7,6 +7,7 @@ before_save { self.user_name = user_name.downcase } Rails looks for the create_remember_token and runs it before anything else + =end before_create :create_remember_token diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 418f2e2..331abd4 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -19,7 +19,7 @@

<%= f.label :password_confirm %>
- <%= f.text_field :password_confirm %> + <%= f.text_field :password_confirmation %>

<%= f.submit %> -- cgit v1.2.3-2-g168b