Ruby on Rails — Onkey Website Project

Before getting started, make sure to download the Postgre for macOS from the official website.

Remove sqlite3:

# Use sqlite3 as the database for Active Record
gem 'sqlite3'

And add Postgres:

# Use Postgres as the database for Active Record
gem 'pg'

Once you’ve updated your Gemfile, run bundle install to update your Gemfile.lock file.

Change settings in config/database.yml

default: &default
adapter: postgresql
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 5000
<<: *default
database: onkey_website_development
<<: *default
database: onkey_website_test
<<: *default
database: onkey_website_production
  • Run rake db:create
  • Run rake db:migrate
  • Run rake db:seed(if you have a seed file)

Machine Learning

Artificial Intelligence: The effort to automate intellectual tasks normally performed by humans.

Machine Learning: Rather than giving the program the rules, an algorithm finds the rules for us.

Neural Network: A form of machine learning that uses a layered representation of data.

  • A generalization of vectors and matrices…


  • Create a new separate model cart.js under models.
  • Instead putting constructor, we’ll just put static methods since cart instance is not being added or deleted every time we add or edit the product, but it could just be there.

We’re importing file system and path so that we can save

Easier Development


  • Node Package Manager
  • Initialize the node project
  • Add some extra features
npm init

Then it’ll create package.json file and you can edit the scripts section, which you can write on the command line instead of the actual command.

"scripts": {
"test": "echo \"Error: no test specified\" &&…

Rails App Structure and Back-end


Separation of presentation layer (what the user of the application sees in the browser/mobile device) and the business logic or back-end (invisible layer)

Models are whatever resources that are used in your app.

Views are what the user sees in the browser or in the mobile devices and comprised of…

Passing and Using Dynamic Data

Adding the Product ID to the Path

We will add an identifier to the end of the url with the product ID.


<a href="/products/<%= %>" class="btn">Details</a>

First, we should assign ID in the model.


module.exports = class Product {
constructor(title, imageUrl, description, price) {…


Sharing Data Across Requests & Users

If we create product array in admin.js and put data in it,

const products = []'/add-product', (req,res,next) => {
products.push({title: req.body.title})

we can export the data to share its data in other files.

exports.products = products;

Then, in shop.js, import the data from admin.js like below,


What is Express.js?



  • Vanilla Node.js
  • Adonis.js
  • Koa
  • Sails.js

Using command

>>> npm install --save express

we are now installing express.js framework.

Why did we omit -dev❓

It is the production dependency. We are not just using this framework as a tool during development but rather as an integral part of our application…

Understanding the Basics

Node.js Lifecycle & Event Loop


const http = require('http');const server = http.createServer((req,res) => {
console.log(req.url, req.method, req.headers);

Run the app.js and reload the page on localhost:3000,

/ GET {
host: 'localhost:3000',
connection: 'keep-alive',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105…


Map Visualization

m = folium.Map(location = [lat,lng], zoom_start = <magnification>)
  • Adding the marker
  • Adding the circle
folium.CircleMarker([lat,lng], radius=<circle_size>).add_to(m)
  • Additional option:
tooltip = "<info shown when hovered>"
popup = "<info shown when clicked>"
  • etc.
# Adding marker when clicked on the mapClickForMarker('<check>').add_to(m)


from folium.plugins import MiniMapm = folium.Map(location = [37.5536067,126.9674308]…

Hyerang Raina Kim

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store