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
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
490
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.5k
Rails の CLI ツールの書き方/writing-rails-cli-tool
sanfrecce_osaka
0
81
Time.zone.parse('dark')/time-zone-parse-dark
sanfrecce_osaka
0
130
外部APIが絡むテストをちょっといい感じに書く/a-little-nice-writing-external-api-testing
sanfrecce_osaka
0
38
gem_rbs_collection へのコントリビュートから始める Ruby の型の世界/contributing-gem-rbs-collection
sanfrecce_osaka
0
630
パターンマッチ使ってるかい?(kyobashi.rb)/use-ruby-s-pattern-matching-on-kyobashi-rb
sanfrecce_osaka
0
300
ApplicationController の継承を分割してエラーを減らした話/dividing-application-controller
sanfrecce_osaka
1
420
Input object ではじめる入力値検証/input-value-validation-using-input-object
sanfrecce_osaka
0
620
実例で学ぶRailsアプリケーションデバッグ入門 〜ログインできちゃってました編〜/rails-application-debug-introduction
sanfrecce_osaka
2
940
Other Decks in Programming
See All in Programming
【QA Test Talk Vol.8】AI-DLC による Whole Team Approach の加速
pkshadeck
PRO
0
250
Hono + Inertia + React で LP を構築した話
oukayuka
2
180
業務時間外もAIに働いてもらう話
colorful12
2
8.7k
freeeにおけるEvalsの実践例の紹介
freee
PRO
0
160
Gmail/Google DriveをトリガーにAIエージェントを動かそう! / Run AI agents with Gmail/Google Drive as triggers!
har1101
3
460
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
550
仕様書を書く前にハーネスを作る - Agent Native開発は「探索を速く、判定を固く」
gotalab555
5
1.8k
S3 を使うアプリケーションをローカル完結で動かすことに全力を注いでみた / Running S3 Apps Offline
contour_gara
0
670
ALB ログから Trace を気合で繋げる技術
fohte
7
770
PyConJP2026_wat_Python × Signal Processing: How to Draw Pictures with Sound Using Spectrogram Art
wat
0
580
プロポーザルを書いてもらう
pvcresin
0
590
My Marp Sample
sinoue0108
0
130
Featured
See All Featured
Heart Work Chapter 1 - Part 1
lfama
PRO
8
36k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
390
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
180
Believing is Seeing
oripsolob
1
200
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
710
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.7k
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
1
2.5k
Facilitating Awesome Meetings
lara
57
7.1k
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