How to Start Ruby on Rails on MacOS
Introduction
Ruby on Rails is a popular web application framework that allows developers to build web applications quickly and easily. If you’re a MacOS user, getting started with Ruby on Rails is a breeze. In this blog post, we’ll walk you through the steps to start Ruby on Rails on your MacOS machine.
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)
Small world. Big idea!
- Welcome to visit the knowledge base of SRE and DevOps!
- License under CC BY-NC 4.0
- No personal information is collected
- Made with Material for MkDocs and generative AI tools
- Copyright issue feedback me#imzye.com, replace # with @
- Get latest SRE news and discuss on Discord Channel