Nora & Zheng initial setup/trello board check#8
Open
npeters5 wants to merge 57 commits into
Open
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
|
CheezItMan
reviewed
Apr 9, 2018
| <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> |
| sprintf('%.2f', (self.cost / 100)) | ||
| end | ||
|
|
||
| def pretty_date |
There was a problem hiding this comment.
👍
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| %> |
| belongs_to :driver | ||
| belongs_to :passenger | ||
| validates :cost, numericality: true | ||
|
|
There was a problem hiding this comment.
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.
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.
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." |
|
|
||
| if @trip | ||
| @trip.destroy | ||
| flash[:notice] = "You successfully deleted this trip." |
There was a problem hiding this comment.
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.
If this is true and the rating is not included, the trip won't be saved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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