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
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
160
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
140
プロダクト価値を、 チームが使える判断軸に変える
vivion
0
130
ファミコンでPHPを動かす / PHP on the Famicom side b
tomzoh
0
140
【データ横丁主催】AI Agentがコンテキストを使って仕事をした後、何が残るのか― 組織の経験を次の判断に引き継ぐ「Agent Memory」
shisyu_gaku
2
330
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
17
120k
freeeらしさをAIとともに作る / Creating the freee Experience with AI
ymrl
0
210
事業活動を AI Ready にする攻めと守りのデータエンジニアリング / data-engineering-for-ai-ready-business
pei0804
3
1.1k
[2026 Oracle Technical Deep Dive] Apache Iceberg × Oracle AI Database -Oracle Autonomous AI Lakehouseが実現するAI時代のデータ基盤- (2026年9月17日開催)
oracle4engineer
PRO
0
120
DWH の限界突破! AI エージェント向け爆速リアルタイムデータ基盤 ClickHouse
jozono
1
210
購入ドメインでの課題と取り組み
ykagano
0
150
Futexes the good, the bad, the ugly
ennael
PRO
0
130
Featured
See All Featured
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
260
The untapped power of vector embeddings
frankvandijk
2
1.9k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
The SEO Collaboration Effect
kristinabergwall1
1
590
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
Embracing the Ebb and Flow
colly
88
5.2k
Designing for humans not robots
tammielis
254
26k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
260
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
620
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Building an army of robots
kneath
307
47k
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のレールから外れよとするととたんに悪夢 がはじまります...