Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
situated-program-challenge Ruby on Rails版
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Fumitaka Tokumitsu
February 13, 2018
Technology
320
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
situated-program-challenge Ruby on Rails版
Fumitaka Tokumitsu
February 13, 2018
Other Decks in Technology
See All in Technology
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
280
会社説明資料
persolserverworks
0
9.8k
UniFi(ユニファイ)AIカメラの現場活用
ludicmind
1
440
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
770
Running Kotlin + Quarkus with Lambda
nealle
1
3.7k
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
120
Rust で関数型ドメインモデリング
takonda
0
140
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
580
今さら理解するウェブフォントver.2026
takanorip
3
770
自作バイナリを動かす「入口」8選
puhitaku
2
1.3k
Gemini Intelligence 入門 ― AppFunctions と Gemini Nano
takuroabe
0
250
ソフトウェア ファクトリー - 再現性のあるソフトウェアの工場づくり / Software factory
iktakahiro
6
4.9k
Featured
See All Featured
[RailsConf 2023] Rails as a piece of cake
palkan
59
7.1k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
370
WENDY [Excerpt]
tessaabrams
14
40k
The Pragmatic Product Professional
lauravandoore
37
7.5k
Paper Plane
katiecoart
PRO
5
54k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
710
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
540
Agile that works and the tools we love
rasmusluckow
331
22k
Done Done
chrislema
187
17k
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
570
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Transcript
situated-program-challenge Ruby on Rails版 • https://github.com/toku345/situated-program-challenge/tree • clj-nakano #4 2018/02/13
• Classi株式会社 徳光史考(@toku345)
Who am I ? toku 3 4 5 徳 光
史 考 Classi 株式会社のRailsエンジニアです Clojure 修行中です!
アジェンダ • Rubyって何? • Railsって何? • version1 実装についてざっくり説明 • まとめ
Ruby って何?
Ruby って何? まつもとゆきひろ(Matz)氏によって開発された動的型 付けオブジェクト指向スクリプト言語。 https://www.ruby-lang.org/ja/
Railsって何?
Rails って? David Heinemeier Hanssonによって開発されたRuby製 Webアプリケーションフレームワーク。 • http://rubyonrails.org/ • https://railsguides.jp/getting_started.html#rails%E3%8
1%A8%E3%81%AF%E4%BD%95%E3%81%8B
Rails の特徴 • MVC • CoC • DRY
Rails MVC
CoC って? Convention over Configuration → 設定より規約を重視する
DRY って? Don't Repeat Yourself → 同じことを繰り返さない
version1 実装 ざっくり説明
version1 実装ざっくり説明 1. プロジェクトの生成 2. 既存DBからschemaファイル生成 3. Model 追加 4.
Rails router 追加 5. Controller 追加 6. View 追加
1. プロジェクトの生成 $ gem install rails $ rails new rest-server
--api -d postgresql ※ 実際に事項したのはこちら↓ $ rails new rest-server --api -T --skip-turbolinks -C -S -B \ -d postgresql --skip-yarn
1. プロジェクトの生成 $ ls ./rest-server Gemfile README.md Rakefile app/ bin/
config/ config.ru db/ lib/ log/ public/ tmp/ vendor/
1. プロジェクトの生成 Gemfile → gem を記述 (project.clj の dependencies) app/
→ model / view / controller などの置き場 config/ → app設定、database 接続設定、route.rb等 の設定ファイル db/ → schemaファイル、migrationファイル等
2. 既存DBからschemaファイル生成 よくあるRailsアプリではDBのschemaの管理を Active Record の migration という機能で管理する ↓ しかし、今回はDBのschema管理はRailsアプリ側で管
理できない...
2. 既存DBからschemaファイル生成 DB から schema ファイルを作成しよう!
2. 既存DBからschemaファイル生成 DBの設定を config/database.yml に記述して
2. 既存DBからschemaファイル生成 $ bundle exec rails db:schema:dump → db/schema.rb が生成される
3. Model 追加
3. Model 追加 Model → ビジネスデータとビジネスロジックを表すシステムの 階層。 ※ Active Record
のおかげで、DBに恒久的に保存され る必要のあるビジネスオブジェクトの作成と利用を円 滑に行なえる。
3. Model 追加 例) Memberモデル
3. Model 追加 例) Memberモデル
3. Model 追加 多対多のリレーション
3. Model 追加 多対多のリレーション groups -* groups_members *- members
3. Model 追加 多対多のリレーション groups -* groups_members *- members
3. Model 追加 多対多のリレーション groups -* groups_members *- members
4. Rails router 追加
4. Rails router 追加 Rails router → 受け取ったURLを認識し、適切なコントローラ内アク ションに割り当てる階層。
↓ 4. Rails router 追加
4. Rails router 追加
↓ 4. Rails router 追加
5. Controller 追加
5. Controller 追加 Controller → リクエストを受け取り、データをモデルから取得したり モデルに保存するなどの作業を行い、最後にビュー を使用してHTML / JSON出力を生成する階層。
5. Controller 追加
5. Controller 追加 ※ ↑ ruby / rails では kebab-case
は扱い辛いので snake_case として扱えるようにする
6. View 追加
6. View 追加 View → Controller で準備された情報をHTML / JSON などのレレ
スポンスデータとして生成する階層。
6. View 追加 GET /members → MembersController の #index アクション
→ app/views/members/index.json.jbuilder
6. View 追加
6. View 追加
6. View 追加 POST /members → MembersController の #create アクション
→ app/views/members/create.json.jbuilder
6. View 追加
6. View 追加
まとめ
まとめ • CoCやDRYといった哲学に基づいたRailsのおかげ で、よくあるWebアプリはサクサクっと作れちゃいま す!
まとめ • ただ、簡単そうな見かけに騙されて、Railsにあまり なれていない方や、経験者でもテキトーに作った り、Railsのレールから外れよとするととたんに悪夢 がはじまります...