-
Notifications
You must be signed in to change notification settings - Fork 26
Sockets - Pauline and Riyo #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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