diff --git a/app/models/product.rb b/app/models/product.rb index 45eef95..af98eb9 100644 --- a/app/models/product.rb +++ b/app/models/product.rb @@ -13,7 +13,7 @@ # avatar_updated_at :datetime # category :integer default("0") # stock :integer default("0"), not null -# calories :integer default("0"), not null // expressed in kcal +# calories :integer default("0") // expressed in kcal # class Product < ActiveRecord::Base @@ -25,7 +25,7 @@ class Product < ActiveRecord::Base validates :name, presence: true validates :price_cents, numericality: { only_integer: true, greater_than_or_equal_to: 0 } validates :stock, numericality: { only_integer: true, greater_than_or_equal_to: 0 } - validates :calories, numericality: { only_integer: true, :allow_nil => true, greater_than_or_equal_to: 0 } + validates :calories, numericality: { only_integer: true, allow_nil: true, greater_than_or_equal_to: 0 } validates_attachment :avatar, presence: true, content_type: { content_type: ["image/jpeg", "image/gif", "image/png"] } diff --git a/app/views/order_items/_order_item.html.erb b/app/views/order_items/_order_item.html.erb index cb18833..2245ebb 100644 --- a/app/views/order_items/_order_item.html.erb +++ b/app/views/order_items/_order_item.html.erb @@ -6,12 +6,12 @@
- <% if product.calories != nil %> - <%= content_tag( :small) do - concat( product.calories) - concat ' kcal' + <% if product.calories %> + <%= content_tag :small do + concat product.calories + concat ' kcal' end - %> + %> <% else %>   <% end %> diff --git a/app/views/products/_product.html.erb b/app/views/products/_product.html.erb index 8ac2416..3ee3c50 100644 --- a/app/views/products/_product.html.erb +++ b/app/views/products/_product.html.erb @@ -5,7 +5,7 @@
- <% if product.calories != nil %> + <% if product.calories %> <%= product.calories %> kcal <% else %>