From 5b3dd7bb6161919763f245c50aa7b635a16efc8e Mon Sep 17 00:00:00 2001 From: Nancy Camacho Date: Thu, 13 Apr 2023 20:17:56 +0000 Subject: [PATCH 1/6] square route --- app/controllers/application_controller.rb | 3 +++ .../calculation_templates/square_form.html.erb | 10 ++++++++++ config/routes.rb | 2 ++ db/development.sqlite3 | Bin 0 -> 20480 bytes db/test.sqlite3 | 0 5 files changed, 15 insertions(+) create mode 100644 app/views/calculation_templates/square_form.html.erb create mode 100644 db/development.sqlite3 create mode 100644 db/test.sqlite3 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index fdd4b2f6..c51a326f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,3 +1,6 @@ class ApplicationController < ActionController::Base + def blank_square_form + render({:template => "calculation_templates/square_form.html.erb" }) + end end diff --git a/app/views/calculation_templates/square_form.html.erb b/app/views/calculation_templates/square_form.html.erb new file mode 100644 index 00000000..d78c5feb --- /dev/null +++ b/app/views/calculation_templates/square_form.html.erb @@ -0,0 +1,10 @@ +

howdy

+ +
+ + + + + + +
diff --git a/config/routes.rb b/config/routes.rb index 9240ef45..06437473 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rails.application.routes.draw do +get("/square/new", { :controller => "application", :action => "blank_square_form"}) + end diff --git a/db/development.sqlite3 b/db/development.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..0246b8db1db6451f6a603fc35cc59bc74cc5ac37 GIT binary patch literal 20480 zcmeI%O;6h}7zc2>FEEg3xb?sRE4@%@P}0yygTt0h)r9DHDdm7TM5Z+(T3(pzM(oJG z&`x|9J_bAOIJ**6r#9!I>Te~k^Y}@V=a*jGoS$_)(NHL17n1cqTb7T ze`y6hD7_r$PdYWu8y3mV`=>SQ4=GhPh;?8+RyHcX^O6yV00bZa0SG_<0uX=z1Rwx` z|03|vD=t@CE&B6F@#{!%8H9-vGT~7W3&jUq@p-Y*r*7NtwOP;q*l9C+UW(1O>~G?S z%`z_gw_LL0lO8+1=ycd=_wb9~y<|u2%eTzVcr+4|EFI`e!Ic;UT-i)tU#Kt^TV8!~ zzD^n4nTh|kjY=luP@g=hc~aT5Ox-UmRWBNOCCq$r;LL=~+Ww9CRjrwB z-E?RWfB*y_009U<00Izz00bZa0SGLrz^W+>>;FZ4yr>HT5P$##AOHafKmY;|fB*y_ zFcvWH|Ecwh=nV}55P$##AOHafKmY;|fB*y_0D;#ba6-$qn(vDw3uT(bB2fd8i734@ z!{%<&-QL~XcACt2x9@uU?%s~)IiBm~&zSfB)Osd*LxTVWAOHafKmY;|fB*y_009U< PU{M4r#oEf$-v@sIg+I%_ literal 0 HcmV?d00001 diff --git a/db/test.sqlite3 b/db/test.sqlite3 new file mode 100644 index 00000000..e69de29b From a4c6683f6b29d0895d9b6bf09c942fd4d3cabffa Mon Sep 17 00:00:00 2001 From: Nancy Camacho Date: Thu, 13 Apr 2023 23:01:01 +0000 Subject: [PATCH 2/6] square --- app/controllers/application_controller.rb | 10 ++++++++++ app/views/calculation_templates/square_form.html.erb | 4 ++-- .../calculation_templates/square_results.html.erb | 10 ++++++++++ config/routes.rb | 2 ++ 4 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 app/views/calculation_templates/square_results.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index c51a326f..56d3641d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -3,4 +3,14 @@ def blank_square_form render({:template => "calculation_templates/square_form.html.erb" }) end + + def calculate_square + + # params = {"elephant" => 42} + + @num = params.fetch("elephant") + @square_of_num = @num ** @num + + render({ :template => "calculation_templates/square_results.html.erb" }) + end end diff --git a/app/views/calculation_templates/square_form.html.erb b/app/views/calculation_templates/square_form.html.erb index d78c5feb..a244d9d4 100644 --- a/app/views/calculation_templates/square_form.html.erb +++ b/app/views/calculation_templates/square_form.html.erb @@ -1,9 +1,9 @@

howdy

-
+ - + diff --git a/app/views/calculation_templates/square_results.html.erb b/app/views/calculation_templates/square_results.html.erb new file mode 100644 index 00000000..f4b27e02 --- /dev/null +++ b/app/views/calculation_templates/square_results.html.erb @@ -0,0 +1,10 @@ +

Square Results

+ +
+
Number
+
<%= @num %>
+ + +
Square
+
<%= @num_of_square %>
+
diff --git a/config/routes.rb b/config/routes.rb index 06437473..f7d1f84f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2,4 +2,6 @@ get("/square/new", { :controller => "application", :action => "blank_square_form"}) +get("/square/results", { :controller => "application", :action => "calculate_square" }) + end From f270645cc0ac801396886a38f2b0a21570f0fcff Mon Sep 17 00:00:00 2001 From: Nancy Camacho Date: Fri, 14 Apr 2023 19:27:34 +0000 Subject: [PATCH 3/6] square totally working --- app/controllers/application_controller.rb | 9 ++++----- .../square_results.html.erb | 4 +++- db/test.sqlite3 | Bin 0 -> 20480 bytes 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 56d3641d..ffd6cf39 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,16 +1,15 @@ class ApplicationController < ActionController::Base def blank_square_form - - render({:template => "calculation_templates/square_form.html.erb" }) + render({ :template => "calculation_templates/square_form.html.erb" }) end def calculate_square # params = {"elephant" => 42} - @num = params.fetch("elephant") - @square_of_num = @num ** @num - + @num = params.fetch("elephant").to_f + @square_of_num = @num ** 2 + render({ :template => "calculation_templates/square_results.html.erb" }) end end diff --git a/app/views/calculation_templates/square_results.html.erb b/app/views/calculation_templates/square_results.html.erb index f4b27e02..2573eb34 100644 --- a/app/views/calculation_templates/square_results.html.erb +++ b/app/views/calculation_templates/square_results.html.erb @@ -6,5 +6,7 @@
Square
-
<%= @num_of_square %>
+
<%= @square_of_num %>
+ +Calculate another square diff --git a/db/test.sqlite3 b/db/test.sqlite3 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..8fc26d15572e67b9ce3d8b90dd723d104b162ae1 100644 GIT binary patch literal 20480 zcmeI&!Ee$~90%~%7B*)x>cw!_!IyFwi5mr42J@iR5NC!{ksTIen%DMK8fnq?LFRG( zPx`-j^iR-}i5Fi9AsAp+FLFKv1Ksuu}P!*LojL7U_bQ55osQbI^^ zzRJz4sj@H3$N5HC8gCjF$>GCqyZSFuDD4sbf&QhmSNgdr8F2_e00Izz00bZa0SG_< z0ucBo0#^fVyKLLa=TpJF5of6zC4#338@VwTEMS7Iixr;qyUw6X2hQVOmm2F*47zW; z=bsEZWvM@8DLs2Jpl9d39(~z=_T1@T(9`b4eQHeEXu=m+GT^722_Cpi7*w90izw#% zt?FWbnKJp1Pi#)9J}qpO-`EO?l7L@kA4l@`*JTqio_%)LeORU zllem)GdGUjrA$QQBwGonf5WWI=PFa4W^(66&5O#GWvY(4RX(q6Dq-coZha-B$t&ts zepT(tRndPFxu8J+0uX=z1Rwwb2tWV=5P$##AaL^pG)2|T+p;d)|KGeH7ZpJO0uX=z z1Rwwb2tWV=5P$##<^lyx-!b#||EhjM^sll*g8&2|009U<00Izz00bZa0SG|gT7i*T zth{xc`5*1GA*=gA)AR$=>#(M2x5B#D_8XyRTXyILVHkK}lkqkSj~Zs9d0<)xb&J+J z#|`V)Y8-Z2)=}%4nG>a0x$8JQnMUb2iFqOf&&2v8nU>w&Jd?lwSM~2i{~ Date: Fri, 14 Apr 2023 20:50:44 +0000 Subject: [PATCH 4/6] added random result --- app/controllers/application_controller.rb | 10 ++++++++++ .../calculation_templates/rand_results.html.erb | 14 ++++++++++++++ config/routes.rb | 1 + 3 files changed, 25 insertions(+) create mode 100644 app/views/calculation_templates/rand_results.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ffd6cf39..ef3ddd12 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -12,4 +12,14 @@ def calculate_square render({ :template => "calculation_templates/square_results.html.erb" }) end + + def calculate_random + + @lower = params.fetch("user_min").to_f + @upper = params.fetch("user_max").to_f + @result = rand(@lower...@upper) + + render({ :template => "calculation_templates/rand_results.html.erb"}) + end + end diff --git a/app/views/calculation_templates/rand_results.html.erb b/app/views/calculation_templates/rand_results.html.erb new file mode 100644 index 00000000..23d6afab --- /dev/null +++ b/app/views/calculation_templates/rand_results.html.erb @@ -0,0 +1,14 @@ +

hi

+ + +
+
Minimum
+
<%= @lower%>
+ +
Maximum
+
<%= @upper %>
+ +
Random Number
+
<%= @result%>
+ +
diff --git a/config/routes.rb b/config/routes.rb index f7d1f84f..a88047ac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,4 +4,5 @@ get("/square/results", { :controller => "application", :action => "calculate_square" }) +get("/random/results", { :controller =>"application", :action => "calculate_random"}) end From 38031e3e9561c08b203cf10aba664d9b6d75a19f Mon Sep 17 00:00:00 2001 From: Nancy-techprep <117962831+Nancy-techprep@users.noreply.github.com> Date: Mon, 17 Apr 2023 17:30:00 +0000 Subject: [PATCH 5/6] fixed issues/reconciled with gitpod --- app/controllers/application_controller.rb | 10 ++++++++++ .../calculation_templates/rand_results.html.erb | 4 +++- ...square_form.html.erb => random_form.html.erb} | 7 ++++++- .../calculation_templates/square_form.html.erbbb | 13 +++++++++++++ .../square_root_form.html.erb | 16 ++++++++++++++++ config/routes.rb | 9 ++++++--- 6 files changed, 54 insertions(+), 5 deletions(-) rename app/views/calculation_templates/{square_form.html.erb => random_form.html.erb} (88%) create mode 100644 app/views/calculation_templates/square_form.html.erbbb create mode 100644 app/views/calculation_templates/square_root_form.html.erb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ef3ddd12..65bf7bde 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -22,4 +22,14 @@ def calculate_random render({ :template => "calculation_templates/rand_results.html.erb"}) end + def blank_random_form + + render({ :template => "calculation_templates/random_form.html.erb" }) + + end + + def blank_square_root_form + + render({ :template => "calculation_templates/square_root_form.html.erb"}) + end end diff --git a/app/views/calculation_templates/rand_results.html.erb b/app/views/calculation_templates/rand_results.html.erb index 23d6afab..35261465 100644 --- a/app/views/calculation_templates/rand_results.html.erb +++ b/app/views/calculation_templates/rand_results.html.erb @@ -1,4 +1,4 @@ -

hi

+

Random Results

@@ -12,3 +12,5 @@
<%= @result%>
+ +
Pick another random number diff --git a/app/views/calculation_templates/square_form.html.erb b/app/views/calculation_templates/random_form.html.erb similarity index 88% rename from app/views/calculation_templates/square_form.html.erb rename to app/views/calculation_templates/random_form.html.erb index a244d9d4..3f971651 100644 --- a/app/views/calculation_templates/square_form.html.erb +++ b/app/views/calculation_templates/random_form.html.erb @@ -1,9 +1,14 @@ -

howdy

+ +
+
+ +
+
diff --git a/app/views/calculation_templates/square_form.html.erbbb b/app/views/calculation_templates/square_form.html.erbbb new file mode 100644 index 00000000..ec522ed4 --- /dev/null +++ b/app/views/calculation_templates/square_form.html.erbbb @@ -0,0 +1,13 @@ +

howdy

+ + + +
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ diff --git a/app/views/calculation_templates/payment_results.html.erb b/app/views/calculation_templates/payment_results.html.erb new file mode 100644 index 00000000..1c2c0ceb --- /dev/null +++ b/app/views/calculation_templates/payment_results.html.erb @@ -0,0 +1,21 @@ + +
+

Payment Results

+
+ +
+ diff --git a/app/views/calculation_templates/rand_results.html.erb b/app/views/calculation_templates/rand_results.html.erb index 35261465..e30b69bb 100644 --- a/app/views/calculation_templates/rand_results.html.erb +++ b/app/views/calculation_templates/rand_results.html.erb @@ -1,4 +1,9 @@ -

Random Results

+
+

Random Results

+
+ +
+
@@ -11,6 +16,8 @@
Random Number
<%= @result%>
-
- Pick another random number + + +
+
diff --git a/app/views/calculation_templates/random_form.html.erb b/app/views/calculation_templates/random_form.html.erb index 3f971651..424db0d4 100644 --- a/app/views/calculation_templates/random_form.html.erb +++ b/app/views/calculation_templates/random_form.html.erb @@ -1,15 +1,15 @@ - - -
- -
- -
- -
- -
- - - -
+ + +
+
+ + +
+
+ + +
+ +
+ + diff --git a/app/views/calculation_templates/square_form.html.erb b/app/views/calculation_templates/square_form.html.erb new file mode 100644 index 00000000..9e434a2c --- /dev/null +++ b/app/views/calculation_templates/square_form.html.erb @@ -0,0 +1,22 @@ + + + + +
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ diff --git a/app/views/calculation_templates/square_form.html.erbbb b/app/views/calculation_templates/square_form.html.erbbb deleted file mode 100644 index ec522ed4..00000000 --- a/app/views/calculation_templates/square_form.html.erbbb +++ /dev/null @@ -1,13 +0,0 @@ -

howdy

- -
- -
- - - diff --git a/app/views/calculation_templates/square_results.html.erb b/app/views/calculation_templates/square_results.html.erb index 2573eb34..0dc0c04a 100644 --- a/app/views/calculation_templates/square_results.html.erb +++ b/app/views/calculation_templates/square_results.html.erb @@ -1,4 +1,8 @@ -

Square Results

+ +
+

Square Results

+
+
Number
diff --git a/app/views/calculation_templates/square_root_form.html.erb b/app/views/calculation_templates/square_root_form.html.erb index 5f6ca09c..346f11b8 100644 --- a/app/views/calculation_templates/square_root_form.html.erb +++ b/app/views/calculation_templates/square_root_form.html.erb @@ -1,16 +1,19 @@ + +
+
- +
+ +
- - +
+ +
-
- - - - -
- - -
+
+ +
+ +
+ diff --git a/app/views/calculation_templates/square_root_results.html.erb b/app/views/calculation_templates/square_root_results.html.erb new file mode 100644 index 00000000..10977492 --- /dev/null +++ b/app/views/calculation_templates/square_root_results.html.erb @@ -0,0 +1,15 @@ +
+

Square Root Results

+
+ +
+
+
+ +
Number:
+
<%= @nums %>
+
Square Root
+
<%= @squareroot_of_num.round(3) %>
+
+
+
diff --git a/config/routes.rb b/config/routes.rb index c5a34efe..31cb3729 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,5 +7,13 @@ get("/random/new", { :controller => "application", :action => "blank_random_form" }) - get("square_root/new", { :controller => "application", :action => "blank_square_root_form" }) + get("square_root/new", { :controller => "application", :action => "square_root_form" }) + + get("square_root/results", { :controller => "application", :action => "square_root_results"}) + + get("payment/new", { :controller => "application", :action => "payment_form" }) + + get("payment/results", { :controller => "application", :action => "payment_results"}) + + end