Skip to content

Latest commit

 

History

History
90 lines (69 loc) · 2.3 KB

README.md

File metadata and controls

90 lines (69 loc) · 2.3 KB

Demo Project for Ruby on Rails

간단하게 Ruby와 Ruby 언어 기반 Web Application Framework Rails를 학습하기 위해 진행하는 데모 프로젝트입니다.

About MVC Pattern

  • Controller : Model & View 연결 매개체
  • Model : 어플리케이션 정보/데이터를 다루는 규칙
  • View : 데이터 표현과 관련된 Ruby 코드가 삽입되어 있는 HTML 파일
+--------+                                 +------------+      
|        |=========(Request)==============>|  route.rb  |
|        |                                 +------------+                    
| Client |                                      ⬇
|        |                +----------+     +------------+            +------------+       |----------| 
|        |<==(Response)===|   View   |  ◀  | Controller | ◀ (Data) ▶ |    Model   | >===< | Database |
+--------+                +----------+     +------------+            +------------+       |----------|


Information

본 데모 프로젝트에 대한 정보입니다.

Spec

  • Ruby Version : ruby 3.2.2
  • Rails Version :
  • Configuration
  • Database
    • creation
    • initialization
  • Deployment instructions
  • Services (job queues, cache servers, search engines, etc.)

Dependencies


Feature


Run & Test


Development

  • routes.rb : ./config 패키지
  • View : ./app/views/{controller name} 패키지
  1. Controller 생성
    • ./app/controllers 패키지에 Controller Ruby 파일이 생성됩니다.
rails generate controller ${NAME}

generate_controller.png

  1. Controller Ruby 파일에 Action 정의
class HomeController < ApplicationController
  # "Index" Action
  def index
    # ...
  end
end
  1. routes.rb 파일 내 Controller Action과 Request Mapping
Rails.application.routes.draw do
  # ...
  
  # 기본 "/" path에 대한 설정이 없으면 Rails 기본 화면이 노출된다.
  get "/index" => "home#index", as: :home
  
  # ...
end
  1. View 구현
    • Action 이름에 맞추어 파일을 생성해야 합니다.

erb : Embedded RuBy

# index.erb
hello world!

generate_controller.png