Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
situated-program-challenge Ruby on Rails版
Search
Fumitaka Tokumitsu
February 13, 2018
Technology
2
300
situated-program-challenge Ruby on Rails版
Fumitaka Tokumitsu
February 13, 2018
Tweet
Share
Other Decks in Technology
See All in Technology
Bill One 開発エンジニア 紹介資料
sansan33
PRO
5
18k
Claude Cowork Plugins を読む - Skills駆動型業務エージェント設計の実像と構造
knishioka
0
260
Datadog Cloud Cost Management で実現するFinOps
taiponrock
PRO
0
140
AI Agentにおける評価指標とAgent GPA
tsho
1
300
kintone開発のプラットフォームエンジニアの紹介
cybozuinsideout
PRO
0
820
Serverless Agent Architecture on Azure / serverless-agent-on-azure
miyake
1
150
Digitization部 紹介資料
sansan33
PRO
1
7k
作りっぱなしで終わらせない! 価値を出し続ける AI エージェントのための「信頼性」設計 / Designing Reliability for AI Agents that Deliver Continuous Value
aoto
PRO
1
130
大規模サービスにおける レガシーコードからReactへの移行
magicpod
1
130
製造業ドメインにおける LLMプロダクト構築: 複雑な文脈へのアプローチ
caddi_eng
1
460
Databricksアシスタントが自分で考えて動く時代に! エージェントモード体験もくもく会
taka_aki
0
320
「ヒットする」+「近い」を同時にかなえるスマートサジェストの作り方.pdf
nakasho
0
110
Featured
See All Featured
Paper Plane
katiecoart
PRO
0
47k
30 Presentation Tips
portentint
PRO
1
250
How to Talk to Developers About Accessibility
jct
2
140
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
450
How to make the Groovebox
asonas
2
2k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
74
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.1k
Prompt Engineering for Job Search
mfonobong
0
180
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
280
Gemini Prompt Engineering: Practical Techniques for Tangible AI Outcomes
mfonobong
2
300
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
54k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
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のレールから外れよとするととたんに悪夢 がはじまります...