/ Setup and Installation / Create a New Rails App

Create New Project

  • Run  a new command with the new project name + “-d mysql” (to configure it to use mysql db)
    rails new quickrails -d mysql


  • Login to mysql
    mysql -u root -p
  • Create new database
    CREATE DATABASE quickrails_development;
  • Create a new Mysql user & grant permission to the database
    GRANT ALL PRIVILEGES ON quickrails_development.*
    TO 'quickrails'@'localhost'
    IDENTIFIED BY 'password'
  • Check whether the permission was correctly granted
    SHOW GRANTS FOR 'quickrails'@'localhost';


Configure Project

  • Open config/database.yml
  • Edit username and password
    default: &default
    adapter: mysql2
    encoding: utf8
    pool: 5
    username: quickrails
    password: quickrails
    socket: /tmp/mysql.sock
    <<: *default
    database: quickrails_development

Create & Configure Homepage

  • Create welcome controller at app/controller/welcome_controller.rb
    class WelcomeController < ApplicationController
      def index
  • Create a welcome folder and index.html.erb under view
    Welcome to quickrails
  • Edit config/routes.rb
    root 'welcome#index'

No video for this post.

No issues for this post.

by ryzalyusoff