A simple product catalog app that returns a couple of mobile phones like iPhone 7, Samsung Galaxy S7 etc. with some simple attributes like product image, title, price, description and color
- Ruby (version 2.7.4)
- Bundler
- Rails API for backend web service
- Rubocop for linting
- Prettier for formating
heroku
for API deployment- Rspec for testing
- Clone the project
git clone https://github.com/bimbolabuari/product-catalog.git
- Install Dependencies
bundle install
- Run Migration with
bundle exec rails db:migrate
- Setup your database with:
bundle exec rails db:setup
# this command will create the database, load the schema, and initialize it with the seed data.
- Start the server using:
rails server
Only one model phone
is used in this app to display the phones.
The phone model has eight (5) attributes (columns) with the following scheme:
-
title
represents thephone_name
stored asstring
on the db. This was done with the assumption that title is not numeric and easy to guess. -
price
is stored asinteger
on the db, TheInteger
is more accurate with arithmetic calculations hence the preference over other similar data types. -
description
,color
andimage
are stored as string. -
created_at
andupdated_at
are auto generateddatetime
See more details in the table below:
Name | Type | Example | |
---|---|---|---|
title | string |
"iPhone 12" |
|
description | string |
"This is the lastest model" |
|
price | integer |
1200 |
|
color | string |
"Gold" |
|
image | string |
"https://upload.wikimedia.org/wikipedia/commons/b/b2/A_photo_of_the_LG_V60_ThinQ_5G.jpg" |
To run the automated test, run
rspec --force-color --format documentation
To run Rubocop by itself, you may run the lint task:
rubocop
Or to automatically fix issues found (where possible):
rubocop -a
You can also check against Prettier:
npx prettier --check "**/*.{html,md,json,yaml,yml}"
and to have it fix (to the best of its ability) any format issues, run:
npx prettier --write "**/*.{html,md,json,yaml,yml}"
- Github: @bimbolabuari
- Twitter: @bimbolabuari
- Linkedin: @bimbolabuari