Giter Site home page Giter Site logo

flatiron-bnb-methods-v-000's Introduction

Flatiron-bnb: Methods

In the previous iteration, we built out our model associations and migrated our database. Now we're going to work on building useful methods (class and instance) for rendering data and our own validations. We're doing this to follow the principle that our controllers should be skinny, our models fat, so therefore our views have very little logic in them.

Before anything, note that when you generate models, controllers, etc, be sure to include this option, so that it skips tests (which we already have): --no-test-framework

Instructions

There are many methods here. Check out the specs and remember to run your code in rails c โ€” that will help, I promise!

City

  • The #city_openings method should return all of the Listing objects that are available for the entire span that is inputted. (NOTE: This isn't easy. Check the resources below and try out a few things in console until you're satisfied with your solution. Don't be afraid to google!)
  • The .highest_ratio_res_to_listings method should return the City that is "most full". What that means is it has the highest amount of reservations per listing.
  • The .most_res method should return the City with the most total number of reservations, no matter if they are all on one listing or otherwise.

Listing

Validations

  • You'll need to write a few validations here, they are all pretty straight forward, just take a look at the tests!

Callbacks

  • Whenever a listing is created, the user attached to that listing should be converted into a "host". This means that the user's host field is set to true
  • Whenever a listing is destroyed (new callback! Google it!) the user attached to that listing should be converted back to a regular user. That means setting the host field to false.

Neighborhood

The same class/instance methods as your City object. Maybe there is a way they can share code?!?!?

Reservation

Validations

  • Should have a checkin and a checkout method.
  • Make sure the guest and host aren't the same user.
  • Make sure any reservation that is made, doesn't conflict with others.
  • Make sure the checkout time is after the check in time.

Note: Remember, if you're having trouble setting up your models' relationships, Google is your friend. There might be ways of designing associations that you haven't encountered yet but that will vastly simplify your code.

Methods

  • #duration gives the duration in days
  • #total_price returns the price using the duration and the price per day of the listing

Review

Validations

  • Should have a description, rating and reservation
  • Reviews should only be created on reservations that exist and have already happened.

Resources

View this lesson on Learn.co

View Flatiron BnB Methods Lab on Learn.co and start learning to code for free.

flatiron-bnb-methods-v-000's People

Contributors

ahimmelstoss avatar annjohn avatar fislabstest avatar fs-lms-test-bot avatar garettarrowood avatar irmiller22 avatar jeffkatzy avatar jmburges avatar kthffmn avatar lizdenhup avatar pletcher avatar preetness avatar sarogers avatar stephaniecoleman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.