Skip to content

Nora & Zheng initial setup/trello board check#8

Open
npeters5 wants to merge 57 commits into
Ada-C9:masterfrom
npeters5:master
Open

Nora & Zheng initial setup/trello board check#8
npeters5 wants to merge 57 commits into
Ada-C9:masterfrom
npeters5:master

Conversation

@npeters5

@npeters5 npeters5 commented Apr 3, 2018

Copy link
Copy Markdown

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

Question Answer
Describe the types of entity relationships you set up in your project and why you set up the relationships that way We set up three entities: Driver, Passenger, and Trip. Drivers have many trips, and passengers have many trips, and a trip belongs to one driver, and belongs to one passenger. We decided that a trip should only have one passenger for now.
Describe the role of model validations in your application In the Driver and Passenger models we used validates_presence_of to make sure that user provides input for certain fields (name, vin, etc), and used validates :cost, numericality: true in the trip model to make sure that cost input is numerical. We also added code to the view to reveal the errors.
How did your team break up the work to be done? We started by translating requirements to tasks on Trello, grouping tasks into like categories, and arranging by highest priority. We finished initial setup of the project together, then split up Passenger and Driver, working on separate branches remotely. Then we came bak together to work on Trip, troubleshoot issues and make to-do lists with smaller subtasks, and collaborated well remotely via Slack, and continuously pushed and pulled to git and deployed to Heroku.
What features did you choose to prioritize in your project, and what features, if any, did you have to set aside to meet the deadline? We chose to set aside most of the styling as lower priority, and chose to focus on things like the 'request trip' link on passenger detail page being hidden if the passenger had unrated trips (this works on localhost, but buggy on Heroku...troubleshooting Heroku logs), inserting a datepicker and drop-down menus in our forms, listing all drivers from highest to lowest rating in index page, and updating driver status from available to unavailable after they are selected for a trip.
What was one thing that your team collectively gained more clarity on after completing this assignment? We gained more clarity on the model and logic inside the model, validations, how params work, as well as resources and nested routes.
What is your Trello URL? https://trello.com/b/bC84mDCv/rideshare-rails
What is the Heroku URL of your deployed application? https://np-zc-ridesharerails.herokuapp.com/

npeters5 and others added 30 commits April 3, 2018 08:47
…lumn. modifies seeds.rb to set all drivers to is_available = true
…strong_params, and change order of list for easy testing
2020dream and others added 26 commits April 5, 2018 21:53
… check and update trip strong params to be consistent with schema
@CheezItMan

Copy link
Copy Markdown

Rideshare-Rails

What We're Looking For

Feature Feedback
Baseline
Appropriate Git Usage with no extraneous files checked in and both partners contributing Check, good number of commits and both partners contributed.
Answered comprehension questions Check
Uses named routes (like _path) Check
RESTful routes utilized Check, nice work not including unused routes
Rideshare Rails Specific Content
Table relationships Check
Validation rules for Models Check, need a validation on Trip where it should be between 1 and 5, and allow nil
Business logic is in the models For the mot part, some things should be in the model that are in the controller.
Database is seeded from the CSV files Check
Trello board is created and utilized in project management Check
Postgres database is used Check
Heroku instance is online Check
The app is styled to create an attractive user interface Minimal styling, but that's not a requirement
Overall You've got a few issues with code in the controller that should be in the model and a few odd things in the TripsController. Check out my notes there and let me know if you have any questions. You did hit all the learning goals. Well done.

<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>

Copy link
Copy Markdown

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?

Comment thread app/models/trip.rb
sprintf('%.2f', (self.cost / 100))
end

def pretty_date

Copy link
Copy Markdown

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| %>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread app/models/trip.rb
belongs_to :driver
belongs_to :passenger
validates :cost, numericality: true

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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."

Copy link
Copy Markdown

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."

Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants