This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def circle | |
@pi = 3.1416 | |
@r = params[:radius] | |
@area = @pi*@radius**2 | |
end | |
Error NoMethodError in AreasController#circle | |
undefined method `**' for nil:NilClass | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def square | |
@a = params[:length_of_side].to_f | |
@area = @a**2 | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TipController < ApplicationController | |
def form | |
@meal_cost = params[:meal] | |
@tip_percent= params[:tip] | |
@amount_of_people= params[:amount] | |
end | |
end | |
def result | |
result = (@meal_cost * @tip_percent/100)/@amount_of_people |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActionView::Template::Error (String can't be coerced into Fixnum): | |
2: <div class="container"> | |
3: <div class="row"> | |
4: <div class="col-md-12"> | |
5: <h3>Add a tip of $ <%= result %> to bring your total amount to $</h3> | |
6: <h3>Each person tips: $</h3> | |
7: </div> | |
8: </div> | |
app/controllers/tip_controller.rb:13:in `*' | |
app/controllers/tip_controller.rb:13:in `result' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is the form html | |
<div class="jumbotron"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-9"> | |
<h1>Tip calculator</h1> | |
</div> | |
</div> | |
</div> |