Skip to content

Instantly share code, notes, and snippets.

@phensalves
Created January 5, 2017 17:15
Show Gist options
  • Save phensalves/dc1ab0d80222921698324b032eb18961 to your computer and use it in GitHub Desktop.
Save phensalves/dc1ab0d80222921698324b032eb18961 to your computer and use it in GitHub Desktop.
def show
load_deals unless mobile_device? || request.format == :js
@deal_weekday = DealWeekday.by_weekday(Weekday.from_slug(params[:weekday])).by_slug(params[:slug]).active.first
if !@deal_weekday || !@deal_weekday.active
flash[:error] = '<strong>Desculpe!</strong> Não encontramos a pedida que você solicitou.'
redirect_to home_path(@city.slug)
return false
end
@deal = @deal_weekday.deal
@taken_count = @deal_weekday.vouchers_taken_count
#@available_count = @deal_weekday.vouchers_limit_count - @deal_weekday.vouchers_taken_count
@available_count = @deal_weekday.available_cache - @deal_weekday.vouchers_taken_count
render 'deals/show'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment