Skip to content
Search

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.

$ sudo gem install rails

Then create a new project as follows.

## 기본 DB설정은 SQLite를 사용한다.
$ rails new [PROJECT_NAME]

## 만약 MySQL 데이터베이스 설정을 사용하고 싶다면 아래와 같이 사용해야 한다.
$ rails new [PROJECT_NAME] —database=mysql

Category

Introduce

## 필요한 젬 설치하기
$ bundle install

## 데이터베이스 생성
$ rake db:create

## 웹서버 시작하기
$ rails server

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.

$ rails generate controller home index

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

See also

Favorite site

How to install

Tools

References


  1. Blog.nacyot.com_-_To_deploy_Ruby_on_Rails_applications_to_Docker.pdf ↩

  2. Railsguidebook.pdf ↩

author Zer0 sitemap