From 2d46e3a7820b27d40292b00a300fdc42a10df1fa Mon Sep 17 00:00:00 2001 From: mollyneu Date: Mon, 16 Sep 2024 15:35:26 -0400 Subject: [PATCH] Added list of bikes and ability to move between bikes and stations --- Gemfile.lock | 5 ++ app/controllers/bikes_controller.rb | 7 ++ app/views/bikes/_row.html.erb | 3 + app/views/bikes/index.html.erb | 19 ++++++ app/views/stations/index.html.erb | 5 +- config/routes.rb | 2 + notes/bike-data.sql | 100 ++++++++++++++++++++++++++++ notes/station-data.sql | 14 ++++ 8 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 app/controllers/bikes_controller.rb create mode 100644 app/views/bikes/_row.html.erb create mode 100644 app/views/bikes/index.html.erb create mode 100644 notes/bike-data.sql create mode 100644 notes/station-data.sql diff --git a/Gemfile.lock b/Gemfile.lock index c3e104938..2266cf9c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -135,6 +135,8 @@ GEM nio4r (2.5.8) nokogiri (1.13.8-arm64-darwin) racc (~> 1.4) + nokogiri (1.13.8-x86_64-darwin) + racc (~> 1.4) nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) public_suffix (5.0.0) @@ -194,6 +196,8 @@ GEM strscan (3.0.4) tailwindcss-rails (2.0.12-arm64-darwin) railties (>= 6.0.0) + tailwindcss-rails (2.0.12-x86_64-darwin) + railties (>= 6.0.0) tailwindcss-rails (2.0.12-x86_64-linux) railties (>= 6.0.0) thor (1.2.1) @@ -223,6 +227,7 @@ GEM PLATFORMS arm64-darwin-20 + x86_64-darwin-23 x86_64-linux DEPENDENCIES diff --git a/app/controllers/bikes_controller.rb b/app/controllers/bikes_controller.rb new file mode 100644 index 000000000..4e572b1d8 --- /dev/null +++ b/app/controllers/bikes_controller.rb @@ -0,0 +1,7 @@ +class BikesController < ApplicationController + + def index + @bikes = Bike.all.order(identifier: :asc) + end + +end diff --git a/app/views/bikes/_row.html.erb b/app/views/bikes/_row.html.erb new file mode 100644 index 000000000..ae2f86cf7 --- /dev/null +++ b/app/views/bikes/_row.html.erb @@ -0,0 +1,3 @@ +
flexbox vertical stretch"> + <%= bike.identifier %>: <%= bike.current_station_id %> +
\ No newline at end of file diff --git a/app/views/bikes/index.html.erb b/app/views/bikes/index.html.erb new file mode 100644 index 000000000..5600b9a50 --- /dev/null +++ b/app/views/bikes/index.html.erb @@ -0,0 +1,19 @@ +
+
+
+ View Stations +
+
+ Welcome to ValetBike Everyone! +
+
+ <% if @bikes.present? %> + <%= render(partial: "bikes/row", collection: @bikes, as: :bike) %> + <% else %> +
+ No bikes found. +
+ <% end %> +
+
+
diff --git a/app/views/stations/index.html.erb b/app/views/stations/index.html.erb index d211dda42..1f3853859 100644 --- a/app/views/stations/index.html.erb +++ b/app/views/stations/index.html.erb @@ -1,7 +1,10 @@
+
+ View Bikes +
- Welcome to ValetBike! + Welcome to ValetBike Everyone!
<% if @stations.present? %> diff --git a/config/routes.rb b/config/routes.rb index f1eb0a0d8..7c4231031 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,3 +1,5 @@ Rails.application.routes.draw do root to: "stations#index" + get "stations", to: "stations#index" + get "bikes", to: "bikes#index" end \ No newline at end of file diff --git a/notes/bike-data.sql b/notes/bike-data.sql new file mode 100644 index 000000000..704b37947 --- /dev/null +++ b/notes/bike-data.sql @@ -0,0 +1,100 @@ +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3849,25,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3740,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7946,29,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6242,22,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6928,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9543,30,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2459,32,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4949,25,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2576,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4647,25,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6868,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4684,31,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3492,33,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3594,30,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4273,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6908,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3176,29,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7169,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7938,26,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5995,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4499,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6813,31,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4329,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9473,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5378,29,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7872,31,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2008,31,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2351,22,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4729,31,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7165,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (1106,33,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (1372,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6730,26,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2699,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (1366,31,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2596,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2663,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3780,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5408,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (8564,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7022,22,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4503,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6884,22,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4757,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (8702,22,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5697,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3434,25,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3684,28,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7522,20,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9824,26,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (8918,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3924,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5335,26,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (8089,25,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (1886,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2525,24,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9192,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5460,25,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2253,30,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5444,29,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7788,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4047,26,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3575,25,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5741,32,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9718,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7437,29,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9348,28,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4292,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2165,26,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2612,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5068,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (1028,22,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9834,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2074,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5111,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7907,20,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3994,23,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5276,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7148,23,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6862,31,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7865,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (1144,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3998,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6669,26,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9189,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7420,33,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (5224,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3047,28,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9494,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (7680,21,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3422,27,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2209,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3622,32,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (2887,33,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (3075,29,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (6541,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (9557,30,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (1758,20,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4033,NULL,now(),now()); +insert into bikes (identifier, current_station_id, created_at, updated_at) values (4683,31,now(),now()); diff --git a/notes/station-data.sql b/notes/station-data.sql new file mode 100644 index 000000000..e3475264b --- /dev/null +++ b/notes/station-data.sql @@ -0,0 +1,14 @@ +insert into stations (identifier, name, address, created_at, updated_at) values (21,'Florence Bank Station','19 Meadow Street Florence MA @ Lilly Library',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (24,'Florence Center','31 Main Street Florence MA',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (30,'Jackson Street','7A-7D Jackson Street Northampton MA',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (25,'Cooley Dickinson Health Care','51 Locust Street Northampton MA',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (29,'State St/Mass Central Rail Trail','State Street/Mass Central Rail Trail',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (33,'Northampton High School','380 Elm Street Northampton MA',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (20,'Village Hill/State Hospital','Village Hill/State Hospital',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (26,'John M Greene Hall/Smith College','1 Chapin Way Northampton MA @ John M. Greene Hall',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (23,'Forbes Library','20 West Street Northampton MA',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (27,'Pulaski Park/Downtown','274 Main Street Northampton MA at Pulaski Park',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (31,'Main Street/Court House','99 Main Street Northampton MA',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (28,'Northampton Train Station','Northampton Train Station',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (32,'Main Street/Bridge Street','1 Bridge Street Northampton MA',now(),now()); +insert into stations (identifier, name, address, created_at, updated_at) values (22,'YMCA/Childs Park','YMCA/Childs Park',now(),now());