diff --git a/app/assets/stylesheets/recipes.scss b/app/assets/stylesheets/recipes.scss index 7aced8c..5c205fb 100644 --- a/app/assets/stylesheets/recipes.scss +++ b/app/assets/stylesheets/recipes.scss @@ -51,6 +51,12 @@ div#ingredient-list, div#step-list { } div.recipe-view { + + .source { + @extend .col-xs-6; + word-wrap: break-word; + } + .ingredients div { padding-bottom: 15px; } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6b3e614..e6bf808 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -14,9 +14,9 @@ class UsersController < ApplicationController end def verify_login - if user = User.authenticate(params[:email], params[:password]) + if user = User.authenticate(params[:username], params[:password]) set_current_user(user) - flash[:notice] = "Welcome, #{user.full_name}" + flash[:notice] = "Welcome, #{user.display_name}" redirect_to root_path else flash[:error] = "Invalid credentials" diff --git a/app/models/recipe_ingredient.rb b/app/models/recipe_ingredient.rb index 26290be..b24ef2e 100644 --- a/app/models/recipe_ingredient.rb +++ b/app/models/recipe_ingredient.rb @@ -22,6 +22,18 @@ class RecipeIngredient < ActiveRecord::Base end end + def display_name + if quantity.present? && units.present? + "#{quantity} #{units} of #{custom_name}" + elsif quantity.present? + "#{quantity} #{custom_name}" + elsif units.present? + "#{units} #{custom_name}" + else + custom_name + end + end + def scale(factor, auto_unit = false) if factor.present? && self.quantity.present? && factor != '1' self.quantity = UnitConversion.convert(self.quantity, factor, nil, nil) diff --git a/app/models/user.rb b/app/models/user.rb index 2df7250..265a353 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -4,8 +4,8 @@ class User < ActiveRecord::Base validates :username, presence: true, uniqueness: { case_sensitive: false } - def self.authenticate(email, password) - find_by_email(email).try(:authenticate, password) + def self.authenticate(username, password) + find_by_username(username).try(:authenticate, password) end def display_name diff --git a/app/views/recipes/show.html.erb b/app/views/recipes/show.html.erb index e1bf423..1bb88c2 100644 --- a/app/views/recipes/show.html.erb +++ b/app/views/recipes/show.html.erb @@ -44,7 +44,7 @@ <% end %> <% if @recipe.source.present? %> -
Source
<%= @recipe.source %>