Ruby on Rails
lastmod 2025-04-29created 2015-02-0925 edits
Rails is a web application framework written in the Ruby language. Rails is designed to make web application programming easier by providing tools that make it easy to set up the initial preparation and assumptions every developer needs when starting development. Rails lets you write less code than other languages and frameworks. Developers who have experienced Rails say that web application development becomes more fun.
How to install
Install Rails as follows.
Then create a new project as follows.
## 기본 DB설정은 SQLite를 사용한다.
$ rails new [PROJECT_NAME]
## 만약 MySQL 데이터베이스 설정을 사용하고 싶다면 아래와 같이 사용해야 한다.
$ rails new [PROJECT_NAME] —database=mysql
Category
Introduce
Directories
| File/Folder | Purpose |
| Gemfile | This file is used to describe the gem dependencies your Rails application needs. |
| README | This file is a brief description of the application. It is used to describe installation and usage. |
| Rakefile | This file contains batch jobs that can be run from the terminal. |
| app/ | Contains the controllers, models, and views for the application. This guide will focus on this folder. |
| config/ | Stores settings such as the application's runtime rules, routing, and database. |
| config.ru | Configuration needed when Rack-based servers start. |
| db/ | Lets you see the current database schema. (Better known as database migrations.) You will learn about migrations briefly. |
| doc/ | Detailed documentation about the application. |
| lib/ | Extension modules for the application. (Not covered in this document.) |
| log/ | Application log files. |
| public/ | The only folder visible from outside. Put images, JavaScript, stylesheets, and other static files here. |
| script/ | Contains Rails scripts. Put scripts related to running, deploying, and executing your application here. |
| test/ | Unit tests, fixtures, and other testing tools. This part is covered by Testing Rails Applications. |
| tmp/ | Temporary files |
| tmp/ | Temporary files |
| vendor/ | A place for third-party code. In a typical Rails application, this holds Ruby gems, the Rails source (if installed within the project), and prepackaged additional plugins. |
Database setting
To use a database, the config/database.yml configuration file (YML) is required. By default in Rails, this file consists of three environment configurations:
- development: the environment used on your development computer.
- test: the environment used for automated testing.
- production: the environment used when deploying the application to the live service.
Create controller
Enter the following.
The following message is printed.
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
create app/controllers/home_controller.rb
route get 'home/index'
invoke erb
create app/views/home
create app/views/home/index.html.erb
invoke test_unit
create test/controllers/home_controller_test.rb
invoke helper
create app/helpers/home_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/home.coffee
invoke scss
create app/assets/stylesheets/home.scss
Rail on Docker
- Youtube: Easy Ruby On Rails deploy on Docker
- Rails on Docker
- Quickstart Guide: Compose and Rails
- Docker for the Really Impatient, Chapter 17 - 1. Installing Ruby and Rails
- [Recommended] Deploying a Ruby on Rails application with Docker (1) Building the application image 1
See also
- Ruby
- Rake
- Vim:Plugin:vim-rails
- WASP - A web framework similar to Rails, based on React/Node/Prisma
- Shardines - Managing per-tenant databases with SQLite in Rails
Favorite site
- Ruby on Rails web site
- Wikipedia (en) Description of Ruby on Rails
- Getting Started with Rails
- [Recommended] Getting Started with Rails
- Rails guidebook for beginners (a.k.a. Chorega) 2
- Ruby on rails or Spring for a startup? (conclusion: use Ruby on rails)
- Ruby on Rails Guides (I translated the latest Rails (8.1) guide documentation into Korean. | GeekNews)