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
Rails と人魚の話/rails-and-mermaid
Search
Masatoshi Moritsuka
April 04, 2024
Programming
510
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Rails と人魚の話/rails-and-mermaid
Masatoshi Moritsuka
April 04, 2024
More Decks by Masatoshi Moritsuka
See All by Masatoshi Moritsuka
拙者、『型は欲しいが型は書きたくない』者たちとの和睦を結び、るびぃにおける型の領地安堵を実現せんと欲す者也 #sekigahara01/sekigahara01
sanfrecce_osaka
4
2.7k
Rails の CLI ツールの書き方/writing-rails-cli-tool
sanfrecce_osaka
0
87
Time.zone.parse('dark')/time-zone-parse-dark
sanfrecce_osaka
0
140
外部APIが絡むテストをちょっといい感じに書く/a-little-nice-writing-external-api-testing
sanfrecce_osaka
0
41
gem_rbs_collection へのコントリビュートから始める Ruby の型の世界/contributing-gem-rbs-collection
sanfrecce_osaka
0
680
パターンマッチ使ってるかい?(kyobashi.rb)/use-ruby-s-pattern-matching-on-kyobashi-rb
sanfrecce_osaka
0
310
ApplicationController の継承を分割してエラーを減らした話/dividing-application-controller
sanfrecce_osaka
1
450
Input object ではじめる入力値検証/input-value-validation-using-input-object
sanfrecce_osaka
0
630
実例で学ぶRailsアプリケーションデバッグ入門 〜ログインできちゃってました編〜/rails-application-debug-introduction
sanfrecce_osaka
2
940
Other Decks in Programming
See All in Programming
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
480
Simple Storage Service(S3) is not simple
iwatsukayura
0
210
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
480
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
Rでドレミ/Do-Re-Mi_with_R
florets1
0
120
Agentic Software Factoryに、すごく賢いIF文を。 / super smart IF statement into the Agentic Software Factory.
rkaga
8
1.9k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
340
The Rails Doctrine Decade
koic
2
510
カツオ、ご期待ください
suneo3476
0
150
20260914 AIエージェント時代のPlatform Engineering LLM基盤とプロダクトの責務境界線
kanfab1
7
2.4k
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
7.5k
大喜利で理解するLLM as a Judge / Understanding LLM-as-a-Judge through Ogiri
rockname
0
190
Featured
See All Featured
Optimizing for Happiness
mojombo
378
71k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
540
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
440
Testing 201, or: Great Expectations
jmmastey
46
8.3k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
The SEO identity crisis: Don't let AI make you average
varn
0
580
Thoughts on Productivity
jonyablonski
76
5.4k
Build your cross-platform service in a week with App Engine
jlugia
234
19k
Technical Leadership for Architectural Decision Making
baasie
3
590
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
510
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
700
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Transcript
Rails と人魚の話 森塚 真年(@sanfrecce_osaka) 2024/04/04 Omotesando.rb#96 #omotesandorb
自己紹介 森塚 真年 @sanfrecce-osaka or @sanfrecce_osaka from: 大阪府枚方市 趣味: コミュニティ・勉強会
Machida.rb ・Hirakata.rb 株式会社エンペイ Ruby3.2/Rails7.0 Node.js v18/Vue.js 3.3/Vuetify 3.4 最近 Layout Cop を全部ドキュメント読んで設 定した
本編
ER 図
何使ってますか?
選択肢 gem gem 以外 DB クライアント(e.g. table plus) rails-erd erd
rails_erd_mermaid rails-mermaid_erd plant_erd
そもそもの要件 graphviz への依存がない エンジニア以外も触れるようにしたい エンペイではエンジニア以外も SQL を書いて いる
選ばれたのは
rails-mermaid_erd でした
rails-mermaid_erd 導入の手順 Gemfile に gem "rails-mermaid_erd", group: :development を追加 bin/rails
mermaid_erd Rails のER 図をMermaid で柔軟に生成できるGem を 作りました Repository Demo Page
できること ER 図の各種エクスポート・コピー Mermaid ・Markdown ・SVG ・PNG リレーションのプレビュー リレーションのコメントの表示 カラムの非表示
キーの表示 カラムコメントの表示 表示対象の絞り込み
できないこと テーブルのコメントの表示 mermaid のコメントとしてなら吐けるので PR 出す予定
裏側の仕組み 1. で model の 定義から Hash を組み立て 2. の
window.SCHEMA_DATA に 1 で組み立てた Hash を json に変換して bind 3. ファイルとして出力(JS 部分は cdn の Vue を使っ ているので html ファイル単体で動く) RailsMermaidErd::Builder.model_data templates/index.html.erb
ところで
そもそもの要件 graphviz への依存がない エンジニア以外も触れるようにしたい エンペイではエンジニア以外も SQL を書いて いる
🤔
そうだ!
migration に hook させて git で 管理しよう! %w(db:migrate db:schema:load).each do
|task| Rake::Task[task].enhance do Rake::Task['mermaid_erd'].invoke if Rails.env.development? end end
あとはこうして models/documentation.rb module Documentation; end
こうして ActiveAdmin.register Documentation do actions :index controller do def index
redirect_to admin_documentations_erd_path end end end
こうして config/routes.rb namespace :admin do namespace :documentations do resource :erd,
only: :show, format: 'html' end end
こうじゃ! config/mermaid_erd.yml result_path: app/views/admin/documentations/erds/show.html.erb
最後に rails-mermaid_erd べんり migration に hook させて更新して git 管理すれば view
として扱える activeadmin 等の管理画面の view ファイルとして 扱えば認証も解決 ( 今後は) 社内で ER 図 の勉強会 をやっていき!
ご清聴 ありがとうございました
None