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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Masatoshi Moritsuka
April 04, 2024
Programming
500
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
86
Time.zone.parse('dark')/time-zone-parse-dark
sanfrecce_osaka
0
140
外部APIが絡むテストをちょっといい感じに書く/a-little-nice-writing-external-api-testing
sanfrecce_osaka
0
40
gem_rbs_collection へのコントリビュートから始める Ruby の型の世界/contributing-gem-rbs-collection
sanfrecce_osaka
0
650
パターンマッチ使ってるかい?(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
手動確認はもう限界 〜XCUITestでCustom URL Schemeの遷移を起動種別ごとに自動テストする〜 / Testing Custom URL Schemes with XCUITest
otouto
0
370
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
150
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
600
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Rails World 2026, Austin, Texas
marcoroth
0
140
KiroのSpecで「五目並べ」を作ってみる
satoshi256kbyte
1
320
巨大モノリシックアプリ モダン化大作戦
ktcryomm
1
1.2k
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
280
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
410
AI Agent時代のリアーキテクチャ戦略と実践
hokaccha
9
5.2k
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
160
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
400
Featured
See All Featured
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
480
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
YesSQL, Process and Tooling at Scale
rocio
174
15k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
310
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
2k
Thoughts on Productivity
jonyablonski
76
5.4k
Site-Speed That Sticks
csswizardry
13
1.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
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