use .nil? instead of == or != symbol
Showing
| ... | @@ -3,12 +3,12 @@ class CardsController < ApplicationController | ... | @@ -3,12 +3,12 @@ class CardsController < ApplicationController |
| def index | def index | ||
| @card_infos = Hash.new | @card_infos = Hash.new | ||
| if session[:SHOPPING_CARD_SESSION_NAME] != nil | if !session[:SHOPPING_CARD_SESSION_NAME].nil? | ||
Please
register
or
sign in
to reply
|
|||
| @card_infos = session[:SHOPPING_CARD_SESSION_NAME] | @card_infos = session[:SHOPPING_CARD_SESSION_NAME] | ||
| end | end | ||
| if params[:product_id] != nil | if !params[:product_id].nil? | ||
| # if remove a product from card | # if remove a product from card | ||
| if params[:card_action] != nil && params[:card_action] == 'remove' | if !params[:card_action].nil? && params[:card_action] == 'remove' | ||
| # Nothing to delete | # Nothing to delete | ||
| if @card_infos.empty? | if @card_infos.empty? | ||
| redirect_to cards_path | redirect_to cards_path | ||
| ... | @@ -24,14 +24,14 @@ class CardsController < ApplicationController | ... | @@ -24,14 +24,14 @@ class CardsController < ApplicationController |
| end | end | ||
| end | end | ||
| end | end | ||
| elsif params[:card_action] != nil && params[:card_action] == 'update' | elsif !params[:card_action].nil? && params[:card_action] == 'update' | ||
| # Nothing to update | # Nothing to update | ||
| if @card_infos.empty? | if @card_infos.empty? | ||
| redirect_to cards_path | redirect_to cards_path | ||
| else | else | ||
| quantity = params[:quantity] | quantity = params[:quantity] | ||
| # Invalid request | # Invalid request | ||
| if quantity == nil || quantity.to_i <= 0 | if quantity.nil? || quantity.to_i <= 0 | ||
| redirect_to cards_path | redirect_to cards_path | ||
| else | else | ||
| card_items = @card_infos[:card_items] | card_items = @card_infos[:card_items] | ||
| ... | @@ -84,7 +84,7 @@ class CardsController < ApplicationController | ... | @@ -84,7 +84,7 @@ class CardsController < ApplicationController |
| def checkout | def checkout | ||
| add_breadcrumb "Checkout", url_for(action: 'checkout') | add_breadcrumb "Checkout", url_for(action: 'checkout') | ||
| @card_infos = Hash.new | @card_infos = Hash.new | ||
| if session[:SHOPPING_CARD_SESSION_NAME] != nil | if !session[:SHOPPING_CARD_SESSION_NAME].nil? | ||
| @card_infos = session[:SHOPPING_CARD_SESSION_NAME] | @card_infos = session[:SHOPPING_CARD_SESSION_NAME] | ||
| end | end | ||
| if @card_infos.empty? | if @card_infos.empty? | ||
| ... | @@ -133,7 +133,7 @@ class CardsController < ApplicationController | ... | @@ -133,7 +133,7 @@ class CardsController < ApplicationController |
| add_breadcrumb "Check out", url_for(action: 'checkout') | add_breadcrumb "Check out", url_for(action: 'checkout') | ||
| add_breadcrumb "Confirm", url_for(action: 'confirm_checkout') | add_breadcrumb "Confirm", url_for(action: 'confirm_checkout') | ||
| @card_infos = Hash.new | @card_infos = Hash.new | ||
| if session[:SHOPPING_CARD_SESSION_NAME] != nil | if !session[:SHOPPING_CARD_SESSION_NAME].nil? | ||
| @card_infos = session[:SHOPPING_CARD_SESSION_NAME] | @card_infos = session[:SHOPPING_CARD_SESSION_NAME] | ||
| end | end | ||
| if @card_infos.empty? | if @card_infos.empty? | ||
| ... | ... |