Skip to content

Ruby on Rails on MacOS

Prepare installation

brew install node
brew install npm
npm install --global yarn
brew install sqlite3
brew install ruby
export PATH="/usr/local/opt/ruby/bin:$PATH"
gem install rails

Confirm version

ruby --version
sqlite3 --version
node --version
yarn --version
bundle exec rails --version

Create new site and run

bundle exec rails new blog
cd blog
bundle exec rails server

Function of default files and folders

  • app/: Contains the controllers, models, views, helpers, mailers, channels, jobs, and assets for your application.
  • bin/: Contains the rails script that starts your app and can contain other scripts you use to set up, update, deploy, or run your application.
  • config/: Contains configuration for your application’s routes, database, and more.
  • config.ru: Rack configuration for Rack-based servers used to start the application.
  • db/: Contains your current database schema, as well as the database migrations.
  • Gemfile.lock: These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem.
  • lib/: Extended modules for your application.
  • log/: Application log files.
  • package.json: This file allows you to specify what npm dependencies are needed for your Rails application.
  • public/: Contains static files and compiled assets. When your app is running, this directory will be exposed as-is.
  • Rakefile: This file locates and loads tasks that can be run from the command line. The task definitions are defined throughout the components of Rails. Rather than changing Rakefile, you should add your own tasks by adding files to the lib/tasks directory of your application.
  • README.md: This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on.
  • storage/: Active Storage files for Disk Service.
  • test/: Unit tests, fixtures, and other test apparatus.
  • tmp/: Temporary files (like cache and pid files).
  • vendor/: A place for all third-party code. In a typical Rails application, this includes vendored gems.
  • .gitignore: This file tells git which files (or patterns) it should ignore.
  • .ruby-version: This file contains the default Ruby version.

Reference

  • Sufyan Bin Uzayr - Mastering Ruby on Rails - A Beginner’s Guide (2022)

Disclaimer
  1. License under CC BY-NC 4.0
  2. Copyright issue feedback: dig +short txt issue.imzye.com
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Buy Me a Coffee