Conversation
…nger column from respective show
… can rate their previous trip regardless of whether there are available drivers
Rideshare RailsWhat We're Looking For
|
| // <h1>Welcome to the Trip List</h1> | ||
|
|
||
| // <ul> | ||
| // <% @trips.each do |driver| %> |
There was a problem hiding this comment.
I'm not sure what happened here. It looks like maybe this file was supposed to be commented out or just not checked in at all.
This seems like it was definitely supposed to look like this though:
| // <% @trips.each do |driver| %> | |
| // <% @trips.each do |trip| %> |
Also the fact that trip doesn't exist causes errors with the rest of the view.
|
|
||
| post '/drivers/:id/available', to: 'drivers#available', as: "driver_availability" | ||
| # post '/drivers/:id/destroy', to: 'drivers#destroy', as: "destroy_driver" | ||
| # post '/passengers/:id/destroy', to: 'passengers#destroy', as: "destroy_passenger" |
There was a problem hiding this comment.
It looks like these were removed at the last minute but were still referenced by tests.
| Total Fare Paid: $<%= @passenger.total_fare %> | ||
| </p> | ||
|
|
||
| <% if @passenger.trips.last.rating == nil %> |
There was a problem hiding this comment.
This causes a test (works for a passenger that exists) to fail. (You will get an undefined method `rating' for nil:NilClass when there are no trips for the passenger.)
It also causes the same error when trying to show a newly created Passenger.
You need to make sure that @passenger.trips.last isn't nil before calling rating:
| <% if @passenger.trips.last.rating == nil %> | |
| <% if @passenger.trips.last && @passenger.trips.last.rating == nil %> |
| return | ||
| end | ||
|
|
||
| if driver.available == true |
There was a problem hiding this comment.
Tip: you can leave off the == true here in Ruby it's implied.
|
|
||
| if driver.available == true | ||
| driver.available = !driver.available | ||
| elsif driver.available == false || driver.available == nil |
There was a problem hiding this comment.
Tip: since false and nil are the only "falsey" objects in Ruby this could simply be:
| elsif driver.available == false || driver.available == nil | |
| elsif !driver.available |
|
|
||
| trip.destroy | ||
|
|
||
| redirect_to trips_path |
There was a problem hiding this comment.
This should redirect to the appropriate Passenger or Driver. See notes on routes.rb.
| @@ -0,0 +1,26 @@ | |||
| <h1>Welcome to the Driver List</h1> | |||
|
|
|||
| <ul> | |||
There was a problem hiding this comment.
Tip: a <table> can make displaying this sort of information easier.
| @@ -0,0 +1,5 @@ | |||
| class AddDriverIdColumnToTrips < ActiveRecord::Migration[5.2] | |||
| def change | |||
| add_reference :trips, :driver, foreign_key: true | |||
There was a problem hiding this comment.
Tip: you are allowed to run multiple commands in a single change method.
| root 'homepages#index' | ||
|
|
||
| resources :drivers | ||
| resources :trips |
There was a problem hiding this comment.
Trips should have been nested under :drivers as well.
| resources :trips | ||
|
|
||
| resources :passengers do | ||
| resources :trips, only: [:index, :new, :create] |
There was a problem hiding this comment.
trips#new shouldn't live here since the passenger isn't treated specially when you make a new trip.
Rideshare-Rails
Congratulations! You're submitting your assignment! These comprehension questions should be answered by both partners together, not by a single teammate.
Comprehension Questions