-
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
Daniela and Jackie F. - Spooky Bus #5
base: master
Are you sure you want to change the base?
Conversation
…onstraint for deleted passengers
Rideshare RailsWhat We're Looking For
|
@@ -0,0 +1,19 @@ | |||
class Passenger < ApplicationRecord | |||
validates :name, presence: true, format: { with:/\A\S+\s{1}.+\z/ , message: "Please enter a first and last name."} |
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.
Nice work with a regex.
@@ -0,0 +1,19 @@ | |||
class Passenger < ApplicationRecord | |||
validates :name, presence: true, format: { with:/\A\S+\s{1}.+\z/ , message: "Please enter a first and last name."} | |||
validates :phone_num, presence: true, format: { with: /\A1?\W?\d{3}.\d{3}.\d{4}.?x?\d*\z/, message: "Please enter a valid phone number in (XXX)XXX-XXXX format."} |
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.
👍
|
||
def total_charges | ||
sum = 0 | ||
self.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 could also use reduce
or another enumerable method.
class Driver < ApplicationRecord | ||
validates_presence_of :vin | ||
validates :name, presence: true, format: { with:/\A\S+\s{1}.+\z/ , message: "Please enter a first and last name."} | ||
|
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 set fo validations and business logic methods, consider using enumerables next project.
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