From b8c14b654255376d79fae55e139a968930be4569 Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Mon, 3 Mar 2014 19:51:30 -0500 Subject: fixed users table --- app/controllers/users_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/controllers') diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6436e4e..c14f67c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -15,9 +15,13 @@ class UsersController < ApplicationController end def show - @user = User.find(param[:id]) + @user = User.find(params[:id]) end + def index + @users = User.all + end + private def user_params -- cgit v1.2.3-54-g00ecf From 661dbaf902d770dfbefa9ba1d9e4c28fc7abf891 Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Mon, 3 Mar 2014 21:49:38 -0500 Subject: small things --- app/assets/stylesheets/scaffolds.css.scss | 1 - app/controllers/sessions_controller.rb | 17 ++++++++++------- app/views/sessions/new.html.erb | 4 +++- app/views/users/index.html.erb | 4 +++- 4 files changed, 16 insertions(+), 10 deletions(-) (limited to 'app/controllers') diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss index dc22c99..f4c3040 100644 --- a/app/assets/stylesheets/scaffolds.css.scss +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -29,7 +29,6 @@ a { } &:hover { color: #000; - font-weight:bold; text-decoration: none; } } diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index 68cb949..3417332 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -1,22 +1,25 @@ class SessionsController < ApplicationController def new + if @user.nil? + @user = User.new + end end # find the user and create a new session def create - user = User.find_by(email: params[:session][:email].downcase) - if user && user.authenticate(params[:session][:password]) - sign_in user + @user = User.find_by(email: params[:session][:email].downcase) + if @user && @user.authenticate(params[:session][:password]) + sign_in @user redirect_to root_path else - render 'new' - end + redirect_to signin_path + end end def destroy - sign_out - redirect_to root_path + sign_out + redirect_to root_path end end diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index f942cf6..2e7a0d3 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -1,5 +1,7 @@

Sign in

- +<% if @fail %> +

Email and password combination not found

+<% end %>
<%= form_for(:session, url: sessions_path) do |f| %> diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index c128661..d92da4d 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -3,6 +3,7 @@ + @@ -14,7 +15,8 @@ <% @users.each do |user| %> - + + -- cgit v1.2.3-54-g00ecf
Username Name Pw hash
<%= link_to("#{user.name}", user, nil) %><%= link_to("#{user.user_name}", user, nil) %><%= user.name %> ******* <%= link_to 'Edit', edit_user_path(user) %> <%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %>