Skip to content

Instantly share code, notes, and snippets.

@sqfmason
Created October 5, 2015 02:12
Show Gist options
  • Save sqfmason/a1568e6fc22149c905e4 to your computer and use it in GitHub Desktop.
Save sqfmason/a1568e6fc22149c905e4 to your computer and use it in GitHub Desktop.
class TipController < ApplicationController
def form
@meal_cost = params[:meal].to_i
@tip_percent= params[:tip].to_i
@amount_of_people= params[:amount].to_i
end
end
def result
@meal_cost = params[:meal].to_i
@tip_percent= params[:tip].to_i
@amount_of_people= params[:amount].to_i
result = (@meal_cost.to_i * @tip_percent/100.to_i)/@amount_of_people.to_i
render result
end
ZeroDivisionError in Tip#result
Showing /Users/Qureshi/Desktop/learning ruby/omnicalc/checkpoint-1/tip_calculator/app/views/tip/result.html.erb where line #5 raised:
divided by 0
Extracted source (around line #14):
@amount_of_people= params[:amount].to_i
result = (@meal_cost.to_i * @tip_percent/100.to_i)/@amount_of_people.to_i
render result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment