-
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
Ports - Jessica & Kasey #9
base: master
Are you sure you want to change the base?
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 |
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.
👍
<p><%= "Form for editing a trip" %></p> | ||
|
||
<%= f.label :date %> | ||
<%= f.datetime_field :date %> |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also use the enumerable method .sum
class Trip < ApplicationRecord | ||
belongs_to :passenger | ||
belongs_to :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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
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.
Spelling
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