
Ruby on Rails(줄여서 Rails)는 Ruby 언어로 작성된 오픈소스 웹 애플리케이션 프레임워크입니다. 2004년 David Heinemeier Hansson이 만든 이 프레임워크는 "개발자의 행복"을 중시하며, 빠르고 효율적인 웹 개발을 가능하게 합니다.
# 단 몇 줄로 CRUD가 완성됩니다
class PostsController < ApplicationController
def index
@posts = Post.published.recent
end
def show
@post = Post.find(params[:id])
end
end
# SQL 없이도 복잡한 쿼리 작성 가능
Post.where(published: true)
.where('created_at > ?', 1.week.ago)
.order(created_at: :desc)
# Gemfile - 필요한 기능을 쉽게 추가
gem 'redcarpet' # 마크다운 처리
gem 'rouge' # 코드 하이라이팅
gem 'bootstrap', '~> 5.1' # UI 프레임워크
app/
├── controllers/ # 요청 처리 로직
├── models/ # 데이터 모델
├── views/ # 화면 표시
└── services/ # 비즈니스 로직 분리
스타트업의 선택
성숙한 생태계
최근 업데이트
# Rails 7의 새로운 기능들
- Hotwire: SPA 없이도 모던한 웹앱
- Import Maps: JavaScript 번들링 간소화
- CSS Bundling: 모던 CSS 워크플로우


markdown_blog/
├── app/
│ ├── controllers/
│ │ ├── application_controller.rb
│ │ └── posts_controller.rb
│ ├── models/
│ │ ├── application_record.rb
│ │ └── post.rb
│ ├── services/
│ │ └── markdown_renderer.rb
│ └── views/
│ ├── layouts/
│ │ └── application.html.erb
│ └── posts/
│ ├── index.html.erb
│ ├── show.html.erb
│ ├── new.html.erb
│ ├── edit.html.erb
│ └── _form.html.erb
├── config/
│ ├── routes.rb
│ └── database.yml
└── db/
└── migrate/
└── 001_create_posts.rb
# app/services/markdown_renderer.rb
class MarkdownRenderer
def self.render(content)
renderer = Redcarpet::Render::HTML.new(
filter_html: true,
hard_wrap: true,
link_attributes: { target: '_blank' }
)
markdown = Redcarpet::Markdown.new(
renderer,
autolink: true,
tables: true,
fenced_code_blocks: true,
strikethrough: true
)
markdown.render(content).html_safe
end
end
# app/models/post.rb
class Post < ApplicationRecord
validates :title, presence: true, length: { minimum: 1, maximum: 255 }
validates :content, presence: true, length: { minimum: 1 }
scope :published, -> { where(published: true) }
scope :recent, -> { order(created_at: :desc) }
def markdown_content
MarkdownRenderer.render(content)
end
def reading_time
words_per_minute = 200
word_count = content.split.size
(word_count / words_per_minute.to_f).ceil
end
def summary(limit = 150)
stripped_content = content.gsub(/[#*`>-]/, '').strip
truncated = stripped_content.length > limit ?
stripped_content[0...limit] + '...' :
stripped_content
truncated
end
end
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
before_action :find_post, only: [:show, :edit, :update, :destroy]
def index
@posts = Post.published.recent
end
def show
end
def new
@post = Post.new
end
def create
@post = Post.new(post_params)
if @post.save
redirect_to @post, notice: '포스트가 성공적으로 작성되었습니다.'
else
render :new
end
end
private
def find_post
@post = Post.find(params[:id])
end
def post_params
params.require(:post).permit(:title, :content, :published)
end
end
<!-- app/views/layouts/application.html.erb -->
<div class="container-fluid">
<div class="row">
<div class="col-lg-8 mx-auto">
<main>
<%= yield %>
</main>
</div>
</div>
</div>
<!-- app/views/posts/_form.html.erb -->
<div class="row">
<div class="col-md-6">
<%= form.text_area :content, class: "form-control",
rows: 20,
placeholder: "마크다운으로 작성하세요..." %>
</div>
<div class="col-md-6">
<div class="markdown-preview border p-3">
<!-- JavaScript로 실시간 미리보기 구현 -->
</div>
</div>
</div>
# 1. 의존성 설치
bundle install
# 2. 데이터베이스 설정
rails db:create
rails db:migrate
rails db:seed
# 3. 서버 실행
rails server
# 4. 브라우저 접속
http://localhost:3000
Rails를 선택한 이유는 단순합니다. 빠르게 아이디어를 실현할 수 있기 때문입니다.
몇 시간 만에 완전히 작동하는 블로그 시스템을 만들 수 있었고, 코드도 읽기 쉽고 유지보수하기 좋습니다. 비록 성능상 한계는 있지만, 개인 프로젝트나 중소규모 서비스에는 여전히 최고의 선택 중 하나라고 생각합니다.
Ruby on Rails는:
2024년 현재도 많은 개발자들이 Rails를 선택하는 이유는 명확합니다. 복잡한 설정 없이 비즈니스 로직에 집중할 수 있고, 풍부한 생태계와 커뮤니티가 뒷받침하고 있기 때문입니다.
앞으로도 Rails는 웹 개발의 좋은 선택지 중 하나로 남을 것 같습니다. 특히 빠른 프로토타이핑과 개발 생산성을 중시하는 환경에서는 여전히 강력한 도구입니다.