Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

概要

学び方

特徴

Ruby on Railsの正体と向き合い方 / What is Ruby on Rails and how to deal with it? - Speaker Deck

歴史

RailsはDHHがBasecamp社(旧名:37signals)でプロダクト開発するために作ったフレームワーク
→ 少人数のスタートアップでのプロトタイプ開発のためのフレームワークだった

RESTful

resourcesベースにRESTfulにルーティングする

そのためResource, Controller, Modelが1:1に対応する。
ModelとDBのテーブルはActiveRecordが1:1対応させる。

# config/routes.rb
Rails.application.routes.draw do
  resources :posts
end
# app/models/post.rb
class Post < ApplicationRecord
  validates :title, presence: true
end
# app/controllers/posts_controller.rb
class PostsController < ApplicationController
  def index
    @posts = Post.order(created_at: :desc)
  end
  ...
end

密結合

  • RailsのModelはユースケースと密結合

  • EntityとRepositoryの役割を担っている

→ Railsの限界:あるModelが複数の異なるユースケースでCRUD操作されるようになったとき、Railsと合わなくなる