-
Notifications
You must be signed in to change notification settings - Fork 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
Nora & Zheng initial setup/trello board check #8
base: master
Are you sure you want to change the base?
Conversation
…ion, partial view form and private params
…_date on trip show page
…tes w/root. creates global nav bar"
…lumn. modifies seeds.rb to set all drivers to is_available = true
…tion. adds form for rating.
…strong_params, and change order of list for easy testing
… check and update trip strong params to be consistent with schema
Rideshare-RailsWhat We're Looking For
|
<li>Total Earnings: $<%= @driver.total_earnings %></li> | ||
<li>Average Rating: <%= @driver.average_rating %></li> | ||
<li>VIN: <%= @driver.vin %></li> | ||
<li>Status: <%= @driver.is_available? ? "Available" : "Unavailable" %> </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.
How do you make a driver available?
sprintf('%.2f', (self.cost / 100)) | ||
end | ||
|
||
def pretty_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.
👍
You'll learn later about view_helpers and that might be more useful later as a view helper.
<%= trip.rating %> | ||
<% else %> | ||
<% @rate_first = true %> | ||
<%= form_for trip 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.
👍
belongs_to :driver | ||
belongs_to :passenger | ||
validates :cost, numericality: 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.
What about validating the rating between 1-5?
@trip = Trip.new | ||
@trip.date = DateTime.now | ||
@trip.cost = rand(9999) | ||
driver = Driver.all.where(is_available: true).sample |
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 would make sense to put a method in Driver to get an available driver.
driver = Driver.all.where(is_available: true).sample | ||
@trip.passenger_id = Passenger.find_by(id: params[:passenger_id]).id | ||
if driver | ||
@trip.driver_id = Driver.all.where(is_available: true).sample.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.
You seem to be finding a driver twice here.
raise ArgumentError.new("Error: Trip not created.") | ||
end | ||
else | ||
flash[:notice] = "No driver is available at this moment." |
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.
Flash notices, sweet!
|
||
if @trip | ||
@trip.destroy | ||
flash[:notice] = "You successfully deleted this 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 should probably redirect someplace, maybe root, maybe back to the passenger or driver.
if @trip.update(trip_params) | ||
|
||
if params[:trip][:cost_in_dollar] | ||
@trip.cost = params[:trip][:cost_in_dollar].to_i * 100 |
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.
If this is true and the rating is not included, the trip won't be saved.
Here's link to Trello board, where we've attached our ERDs: https://trello.com/b/bC84mDCv
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