From a421aace7383bb6718d23eed1bde02659a7a93ff Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Thu, 6 Mar 2014 15:57:26 -0500 Subject: login fixed and some views look better --- app/assets/stylesheets/custom.css.scss | 17 +++++++++-------- app/controllers/sessions_controller.rb | 6 +----- app/models/tournament.rb | 1 + app/views/games/index.html.erb | 2 +- app/views/sessions/new.html.erb | 22 +++++++++++----------- app/views/tournaments/_selected.html.erb | 2 +- app/views/users/new.html.erb | 6 +++--- 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/app/assets/stylesheets/custom.css.scss b/app/assets/stylesheets/custom.css.scss index ab86ce9..4ea86d4 100644 --- a/app/assets/stylesheets/custom.css.scss +++ b/app/assets/stylesheets/custom.css.scss @@ -7,14 +7,7 @@ header > nav { #log-buttons { margin-top: 8px; - form { display: inline; } - a, input[type="submit"] { - @extend .btn; - &.user { @extend .btn-info; } - &.signup { @extend .btn-success; } - &.signin { @extend .btn-info; } - &.signout { @extend .btn-danger; } - } + form { display: inline; } } form.search { @extend .navbar-form; @@ -25,6 +18,14 @@ header > nav { } } +a, input[type="submit"] { + @extend .btn; + &.user { @extend .btn-info; } + &.signup { @extend .btn-success; } + &.signin { @extend .btn-info; } + &.signout { @extend .btn-danger; } +} + p.errors { background-color: #FCF8C7; color: red; diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb index f857f27..d5c59d4 100644 --- a/app/controllers/sessions_controller.rb +++ b/app/controllers/sessions_controller.rb @@ -12,11 +12,7 @@ class SessionsController < ApplicationController def create # find the user... - @user = User.find_by(email: params[:session][:email]) - - if @user.nil? - @user = User.find_by_user_name(params[:session][:user_name]) - end + @user = User.find_by_email(params[:session][:username_or_email]) || User.find_by_user_name(params[:session][:username_or_email]) #@session = Session.new(@user) # ... and create a new session diff --git a/app/models/tournament.rb b/app/models/tournament.rb index cc915a0..5e8ddfe 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -1,3 +1,4 @@ class Tournament < ActiveRecord::Base belongs_to :game + has_many :matches end diff --git a/app/views/games/index.html.erb b/app/views/games/index.html.erb index 7ee69d1..9893cbc 100644 --- a/app/views/games/index.html.erb +++ b/app/views/games/index.html.erb @@ -1,6 +1,6 @@

Listing games

- +
diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 6d73b1f..6439b9f 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -2,22 +2,22 @@ <% if @user.nil? %>

The email or password is incorrect. Verify that CAPS LOCK is not on, and then retype the current email and password.

<% end %> -
+
<%= form_for(:session, url: sessions_path) do |f| %> - - <%= f.label :email %> - <%= f.text_field :email%> - - <%= f.label :user_name %> - <%= f.text_field :user_name%> - - <%= f.label :password %> +

+ <%= f.label(:username_or_email, "Username/Email") %>
+ <%= f.text_field :username_or_email%> +

+

+ <%= f.label :password %>
<%= f.password_field :password %> - +

+

<%= f.submit "Sign in", class: "btn btn-large btn-primary" %> +

<% end %>

New user? <%= link_to "Sign up now!", new_user_path %>

-
+ diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb index 4277d8e..5058c56 100644 --- a/app/views/tournaments/_selected.html.erb +++ b/app/views/tournaments/_selected.html.erb @@ -18,7 +18,7 @@ <% next %> <% end %> <% if name == "created_at" %> - <% break %> + <% break %> <% end %>

diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 704aa10..c23f76d 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -19,14 +19,14 @@ <%= f.password_field :password %>

- <%= f.label :password_confirm %>
+ <%= f.label(:password_confirmation, "Confirm Password") %>
<%= f.password_field :password_confirmation %>

- <%= f.submit %> + <%= f.submit("Be a Leaguer", :class => "signup") %>

<% end %> -<%= link_to 'Already Have an Account? Log in', new_session_path, :class => "btn btn-warning btn-lg" %> +<%= link_to 'Already Have an Account? Log in', new_session_path, :class => "signin" %> -- cgit v1.2.3
Name