Conversation
…avigation to get to all of them from every page
…hods so they don't store floats
…stead of two identical ones but I don't know how to references it from two different folders)
…AND id and added validation for trip
…at need to be fixed
Rideshare RailsWhat We're Looking For
|
| must_redirect_to drivers_path | ||
| end | ||
|
|
||
| it "deletes trips associated with driver (but not passenger)" do |
| <p><%= "Form for editing a trip" %></p> | ||
|
|
||
| <%= f.label :date %> | ||
| <%= f.datetime_field :date %> |
There was a problem hiding this comment.
Just a note, if I use the field to pick a date, I get a front-end validation error.
| resources :drivers | ||
|
|
||
| resources :passengers do | ||
| resources :trips |
There was a problem hiding this comment.
You should limit this to only the routes you need, like:
resources :passengers do
resources :trips, only [:create]
end
resources :trips, only [:update, :edit]| resources :passengers do | ||
| resources :trips | ||
| end | ||
|
|
There was a problem hiding this comment.
Missing routes to put a driver online/offline and to mark a trip complete.
| @@ -0,0 +1,29 @@ | |||
| <h2>trips:</h2> | |||
There was a problem hiding this comment.
No output of validation errors are here
| def total_charged | ||
| return 0 if trips.length == 0 | ||
| sum = 0 | ||
| trips.each do |trip| |
There was a problem hiding this comment.
You can also use the enumerable method .sum
| class Trip < ApplicationRecord | ||
| belongs_to :passenger | ||
| belongs_to :driver | ||
|
|
There was a problem hiding this comment.
You don't need to write validations for the foreign key relationships. Rails does that by default.
You could also add validations to limit the values that the rating could be, and to limit the cost to be greater than 0.
| has_many :trips | ||
| validates :name, presence: true | ||
| validates :phone_num, presence: true | ||
|
|
There was a problem hiding this comment.
I suggest you consider making a request_trip business logic method in the Passenger model here, then you could call it from the controller, and dry up that method
| must_respond_with :redirect | ||
| end | ||
|
|
||
| it "should respond with a 422 if it doesn't crete" do |
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