diff options
author | DavisLWebb <davislwebb@ymail.com> | 2014-03-02 20:06:40 -0500 |
---|---|---|
committer | DavisLWebb <davislwebb@ymail.com> | 2014-03-02 20:06:40 -0500 |
commit | e6b2993ad072d0cad2e52997c7957aae0a03415c (patch) | |
tree | be7b89d7a81b934d4d5376abd17db9e769b3fd43 | |
parent | e5e485551fb757873f64cc35505426bec1b5da0d (diff) |
I changed the user controller
-rw-r--r-- | app/controllers/sessions_controller.rb | 8 | ||||
-rw-r--r-- | app/controllers/users_controller.rb | 9 | ||||
-rw-r--r-- | app/models/user.rb | 1 | ||||
-rw-r--r-- | app/views/users/new.html.erb | 2 | ||||
-rw-r--r-- | config/routes.rb | 4 |
5 files changed, 14 insertions, 10 deletions
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 @@ </p> <p> <%= f.label :password_confirm %><br> - <%= f.text_field :password_confirm %> + <%= f.text_field :password_confirmation %> </p> <p> <%= f.submit %> diff --git a/config/routes.rb b/config/routes.rb index a4f1f66..cbe6c2f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,8 @@ Leaguer::Application.routes.draw do #creates sessions as a resource but limits it to these actions resources :sessions, only: [:new, :create, :destroy] + resources :users + match 'signup', to: 'users#new', via: 'get' match 'signin', to: 'sessions#new', via: 'get' match 'signout', to: 'sessions#destroy', via: 'delete' @@ -11,8 +13,6 @@ Leaguer::Application.routes.draw do resources :alerts - resources :users - resources :teams resources :matches |