-
Notifications
You must be signed in to change notification settings - Fork 26
Michelle & Barbara - Edges - Rideshare-Rails #24
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
deleted everything in passenger viewer index file
getting master up to date
adding passenger_work commits to master
Merge origin master with trip_work branch
Merge master branch with trip_work_create_trip
Merge master to trip_work_create_trip
Merge master with trip_work_create_trip
Rideshare RailsWhat We're Looking For
Good work overall. This site's code is well-written and clear. You make good use of validations and model methods, and it's clear to me that the learning goals for this week were met. Aside from the many nitpicks that are inevitable on a project of this size, the two things that I would like you to review are model relations and routing with |
|
|
||
| driver_trips = self.trips.where(driver_id: id) | ||
| num_of_trips = driver_trips.count | ||
|
|
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.
Line 10 is redundant - self.trips will only return trips for this driver, which means all of them have the correct driver ID.
| validates :driver_id, presence: true | ||
| validates :passenger_id, presence: 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.
The belongs_to relationship should already validate the driver ID and passenger ID, so you do not need to do so explicitly.
| def new | ||
| @trip = Trip.new | ||
| end | ||
|
|
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 controller action is not used. The link to request a trip goes directly to the create action, bypassing the new form.
| first_avail_driver = all_avail_drivers.first | ||
|
|
||
| passenger_id = params[:passenger_id] | ||
| @trip = Trip.new( |
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.
All of the work done in this method could be moved to a model method. An instance method on Passenger would probably work well, something like Passenger#request_trip.
Note that you can call methods of one model from another model, so Passenger#request_trip could call Driver.where(available: true).
| @@ -0,0 +1,21 @@ | |||
| <%= action_title %> | |||
|
|
|||
| <%= form_with model: @driver do |f| %> | |||
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 glad you're using a view partial here, but I don't know that I agree with the name of this one. The file name should probably include the word form.
| <!-- QUESTION: render partial to DRY code?? --> | ||
| <h3>Driver Trips</h3> | ||
| <table> | ||
| <thead> |
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.
<!-- ANSWER: yes, I love that idea! -->
| @@ -0,0 +1,44 @@ | |||
| <table> | |||
| <thead> | |||
| <tr> | |||
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 doesn't look like this partial is being used anywhere.
| # NOTE: added nested routes for passengers+trips | ||
| resources :passengers do | ||
| resources :trips, include: [:index, :show, :new, :delete] | ||
| end |
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.
You shouldn't need to nest the :delete route, since :delete already has the trip ID, which means you can figure out the passenger ID.
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.
Also, you include :new here but it's not used in your application, and you exclude :create but do use it. I'll be honest, I'm not quite sure how the link to request a trip from the passenger show page works.
| def availability | ||
| @driver = Driver.find_by(id: params[:driver_id]) | ||
| is_available = @driver.available | ||
|
|
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.
You have a route and controller action to set the availability, but as far as I can tell it is not used in your application. Nowhere is there a link to the availability_path.
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