_You've in the running for a freelance development job as the developer for Mario's Speciality Food Products (or another fictional company of your choosing). First, Mario wants to make sure you're the right person for the job. He's asked you for an MVP and wants it by 5:00 tonight. The stakes are higher than usual, since Mario's old site had thousands of unique visitors each day. If you can get the job, this is a great way to increase your profile as a developer. In particular, Mario is concerned about the information in his database being correct; your goal for today is to have the most comprehensive validations and callbacks to ensure information is properly saved and formatted in the database.
Database The site should have functionality to review products so your database should include a one-to-many relationship between Products and Reviews. All products must have a name, cost and country_of_origin. All reviews should have an author, content_body and rating. (A rating can be a number between 1 and 5.) You can include other fields of your choosing as well._
- Clone this repository
- Open terminal and type 'git clone [git link]'
- Navigate to project directory using cd in terminal
- Open project in text editor (atom .)
- Type 'bundle install' in terminal to load Gems (if you have capybara version incompatible issue with current version of ruby, try "/Users/[User Name]/.rubies/ruby-2.6.3/bin/bundle install" instead of "bundle install"
- To run tests, type 'rspec' in terminal
- postgres DB installation with sql script in project (if your Postgres DB is not starting at login, please execute "pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start" on terminal.
- _for database backup, please execute followings in terminal,
- pg_dump [YOUR DATABASE NAME] > database_backup.sql
- _for database restore after clone, please execute followings in terminal
- createdb [DATABASE NAME]
- psql [DATABASE_NAME] < database_backup.sql
- createdb -T [DATABASE NAME] [TEST DATABASE NAME]
| Behavior | Input | Output |
|---|---|---|
| DB schema design for one-to-many relationship | create products table | |
| make CURD logic for application | create model for product | |
| DB schema design for one-to-many relationship | create reviews table | |
| DB schema design for one-to-many relationship | set up foreign_key with dependent | |
| Testing with Rspec and Shoulda Matchers | rspec | 2 examples, 0 failures |
| Routing with Rails (Nested Routing with Rails) | ||
| creating Rails Controllers | ||
| creating Views with link_to method | ||
| creating Active Record Validations features | ||
| creating database seeding using faker gem | rake db:seed | "Created 50 products", "Created 250 reviews" |
| creating callbacks features with rspec test | ||
| creating Flash message features | ||
| creating validation tests for char_length, range of rating, class of product and review | ||
| creating scope features for most_reviewed, local_product, three_most_recent records | test on rails console | |
| It didn't have timpstamps column in db and so the most recent products cannot be generated by created_at logic in scope, | ||
| We fix it with the remove of current data and table and new migration step for timestamps and recreate data using seed with faker | ||
| creating scope feature for three_most_recent product in landing page |
No known bugs
Please contact us if you have any issues at: [email protected]
- Ruby 2.6.3
- RubyGems
- Atom
- GitHub
- Postgres DB 11.4
- for faker practice, use the faker information on https://www.rubydoc.info/gems/faker/1.6.6#fakervehicle site for test.
This software is licensed under MIT license.
Copyright (c) 2019 _Tae Lee