-
Notifications
You must be signed in to change notification settings - Fork 26
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
Carly and Goeun - Edges - Rail Rideshare #13
base: master
Are you sure you want to change the base?
Conversation
…plates for Driver.
Gp/passenger
… nested routesgit add app/controllers/passengers_controller.rb
Rideshare RailsWhat We're Looking For
Great work Carly and Goeun! The project looks great-- I'm a huge fan of the code and how it looks. It also hits the requirements, particularly the ones we had on models. In particular, the code you two wrote for the routes and controllers are fantastic! good job on routes! This was a challenge for many pairs but I'm happy with where you all landed up! Here's one more bug that I want to call out: "Minnie Dach I have a few other comments on the code, but otherwise, great work overall. PS: i dont know who mistr toad is BUT I LOVE MR TOADS WILD RIDESHARE AND HIS FACE ON THE PAGE!!!!!!!!!!!!!!! IT MAKES ME SO HAPY!!!!!!!!!!!!! |
|
||
def create | ||
passenger = Passenger.find_by(id: params[:passenger_id]) | ||
driver = Driver.find_by(status: 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.
I think this is a really great way to assign drivers!
num_trips = self.trips.length | ||
money = 0 | ||
|
||
num_trips.times do |i| |
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.
Instead of using a times
loop, it may be better to think of this problem as iterating through the collection of self.trips
, so I would prefer maybe to use an each
loop instead.
end | ||
end | ||
|
||
rating = rating.to_f/(num_trips-ongoing_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.
you end up needing the ongoing_trips
variable to keep track of the length of this collection... Maybe there's a different way to filter or select ( https://ruby-doc.org/core-2.5.1/Enumerable.html#method-i-select ), and use that collection...
ongoing_trips = 0 | ||
rating = 0 | ||
|
||
num_trips.times do |i| |
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.
Why not use an each
loop here?
validates :name, presence: true | ||
validates :phone_num, presence:true | ||
|
||
def spent |
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 is subtle, but I like the name of this method :c)
<li><strong>Trip: <%=trip.id %></strong></li> | ||
<li>Date: <%=trip.date %></li> | ||
<% if trip.cost == nil %> | ||
<li>Cost: Ride in progress</li> |
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.
Good choice! There wasn't a requirement about what to do with the trip's cost, so we asked you all to make a decision on it... I like this decision!
</div> | ||
|
||
<% if trip.driver_id %> | ||
<%=link_to "Driver", driver_trips_path(trip.driver_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.
This link just says "Driver". Why not use the driver's name?
</div> | ||
|
||
<% if trip.driver_id %> | ||
<%=link_to "Driver", driver_trips_path(trip.driver_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.
Should this actually go to this path? When I click here, I actually can't tell who the driver is still.
Comprehension Questions