Merge pull request #80 from ZeusWPI/helper_method_for_guest
Add better helper
This commit is contained in:
commit
871e36a293
2 changed files with 6 additions and 2 deletions
|
@ -19,7 +19,7 @@ class Order < ActiveRecord::Base
|
|||
|
||||
before_validation :calculate_price
|
||||
before_save { |o| o.order_items = o.order_items.reject{ |oi| oi.count == 0 } }
|
||||
after_create :create_api_job, unless: -> { user.name == "Guest" }
|
||||
after_create :create_api_job, unless: -> { user.guest? }
|
||||
|
||||
validates :user, presence: true
|
||||
validates_associated :order_items
|
||||
|
@ -35,7 +35,7 @@ class Order < ActiveRecord::Base
|
|||
|
||||
def flash_success
|
||||
f = "#{to_sentence} ordered."
|
||||
f << " Please put #{euro_from_cents(price_cents)} in our pot!" if user.name == "Guest"
|
||||
f << " Please put #{euro_from_cents(price_cents)} in our pot!" if user.guest?
|
||||
f << " Enjoy it!"
|
||||
end
|
||||
|
||||
|
|
|
@ -61,4 +61,8 @@ class User < ActiveRecord::Base
|
|||
user.avatar = File.new(File.join("app", "assets", "images", "guest.png"))
|
||||
end
|
||||
end
|
||||
|
||||
def guest?
|
||||
self == User.guest
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue