rails-erd 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96a5321997e7b69697914d2555515de577676734e66f60cf0b76ff6c6f307846
4
- data.tar.gz: 973f6409aeb4fcd221659e4c9dabadd4a32a047218ea056b4b24b9c71476454c
3
+ metadata.gz: 07a38b05691f97bf85079684c7412bff0bf8b4caf737f52479d2209b3fb2fe5f
4
+ data.tar.gz: c8f38108442a38b331cff3b2c0b856584943ac3def5cec0525255c53595e0482
5
5
  SHA512:
6
- metadata.gz: c5b98489174be741cf8056040f3a6eadd2c5ab673dfb9463b2db0b4fe7e9209a742765464b02c842b859c700231285cae40cfbcbe4eca3bed24d3cf1a191b453
7
- data.tar.gz: 3793cbe2da98c90a4e379864e7dd5e3d4072248ff8245dfa5dfc75d0957e9c9e1f6aab4140ec54af00010312c53791e513e3898b41e2669c365802151497d9aa
6
+ metadata.gz: 146e37a81b1f2008f28442f62498822845810a45bb9a5ab1ba35fec8700be809ba2eac95be388a15878e9ff44d7dc5b4abd8b4db8b479871a993a93668d75337
7
+ data.tar.gz: 9e5d0c84231120c3e1b804950265a3a6abca1201f46f99bd96b3a0655e46c13bdbb0e7ff0403902f621506de81240818cc7135f92423f8a1be0e50c2468629d2
data/CHANGES.md ADDED
@@ -0,0 +1,335 @@
1
+ 2.1.0
2
+ -----
3
+
4
+ ### New Features
5
+ * Add `cluster: true` support for Mermaid `classDiagram` output, grouping entities by Ruby namespace into Mermaid `namespace { }` blocks (#479, #480)
6
+ * Add glob and regex pattern support for `exclude` and `only` options, allowing entire namespaces to be filtered with patterns like `"SolidQueue::*"` or `"/^Active/"` (#465, #478)
7
+ * Add tbls JSON generator for integration with Liam ERD and other tbls-compatible tools (#471, #474)
8
+
9
+ ### Bug Fixes
10
+ * Invalid generator option now falls back to mermaid (the documented default) instead of graphviz
11
+ * Fix unparseable Mermaid output when `polymorphism` is enabled and an abstract parent has a tableless child (#459, #463)
12
+ * Fix `only`/`exclude` not filtering relationships, so filtered-out models no longer leak back into Mermaid diagrams as phantom nodes (#472, #473)
13
+ * Process models in a stable order so relationship order and source/destination direction are deterministic across runs, avoiding churn in generated diagrams committed to version control (#475, #476)
14
+
15
+ ### Internal
16
+ * Restructure `filtered_attributes` for readability and add edge-case tests for `exclude_attributes` normalization (#458)
17
+ * Fix README to show the correct command-line flag syntax for ERD generator options (#461)
18
+ * Add a native Mermaid preview diagram to the README (#466)
19
+ * Fix stale `LICENSE`/`CHANGES.rdoc` references in the YARD task and gemspec so the license and changelog are documented and packaged (#469)
20
+ * Update LICENSE copyright year to 2026 (#468)
21
+
22
+ 2.0.2
23
+ -----
24
+
25
+ ### Features
26
+ * Add `exclude_attributes` option to hide attributes on a per-model basis (#421, #457)
27
+
28
+ ### Bug Fixes
29
+ * Fix crash when using `exclude` option with polymorphic associations on Rails 8 (#454, #455, #456)
30
+
31
+ 2.0.1
32
+ -----
33
+
34
+ ### Bug Fixes
35
+ * Fix mermaid syntax errors for namespaced class names (#450, #451)
36
+ * Fix test helper to correctly create namespaced models (#451)
37
+
38
+ ### Internal
39
+ * Use temp directory for test output files (#453)
40
+
41
+ 2.0.0
42
+ -----
43
+
44
+ ### Breaking Changes
45
+ * Default generator changed from Graphviz to Mermaid (#448)
46
+ * Default filetype changed from PDF to MMD (#448)
47
+ * Default mermaid_style changed from classDiagram to erDiagram (#448)
48
+ * Default direction changed from RL to TB (top-down) (#448)
49
+ * ruby-graphviz gem is now optional (#448)
50
+
51
+ ### New Features
52
+ * Mermaid erDiagram style with crow's foot notation and PK/FK markers (#445)
53
+ * CLI now supports all options that rake task supports (#446, #447)
54
+ * Mermaid direction respects orientation option (#448)
55
+
56
+ ### Bug Fixes
57
+ * Fix --only flag with single model (#441)
58
+ * Fix nil destination crash (#440)
59
+ * Fix empty .erdconfig crash (#443)
60
+ * Fix CLI string-to-symbol option conversion (#447)
61
+ * Exclude Rails 8 Solid* internal models (#437, #438, #439)
62
+ * Suppress Ruby 3.4 hash key warnings (#436)
63
+
64
+ ### Documentation
65
+ * Updated README for Mermaid as default (#444, #448)
66
+ * Added non-Rails usage example (#444)
67
+
68
+ 1.7.2
69
+ -----
70
+ * Suppress warnings for tableless Rails models (#390)
71
+ * Fix example erdconfig foreign keys (docs) (#392)
72
+ * Replace CI badge from Travis to GH Actions (#393)
73
+ * Fix spelling error in error msg (#394)
74
+ * Handle deprecated direct_descendants (#395)
75
+ * Map foreign keys & current column name to symbols (#397)
76
+
77
+ 1.7.1
78
+ -----
79
+ * Fix for frozen string error (#382)
80
+ * Updated graphviz docs for linux (#351)
81
+
82
+ 1.7.0
83
+ -----
84
+ * Added support for Rails 7.0 and Ruby 3.0 (#379)
85
+ * Added optional configuration to set which fonts to use (#378)
86
+ * Improvements to rake tasks (#333, #373)
87
+ * Made loading environment.rb optional (#371)
88
+
89
+
90
+ 1.6.1
91
+ -----
92
+ * Added support for Rails 6.1 (#365)
93
+
94
+ 1.6.0
95
+ -----
96
+ * Dropping support for Ruby < 2.2 and Rails < 4.2 (#323)
97
+ * Added early support for Rails 6.0 (#329)
98
+ * Documentation updates (#268, #269, #276, #288, #295)
99
+ * Removed restriction that allowed to exclude only models from a diagram (#279)
100
+ * Added additional margins to cluster (#280)
101
+ * Deprecate safe_level of ERB.new in Ruby 2.6 (#297)
102
+ * Fixed only_recursion_depth option failure when used from rake erd task (#266, #324)
103
+ * Allow extra config files to be listed via cli (#275, #326)
104
+ * Fixed long-standing segfault issue by removing identifier from association_identity (#296, #327)
105
+ * Fix for bug when parameter to only option is a single model (#300, #328)
106
+ * Properly handle custom version classes. (#304, #325)
107
+ * Fixed a warning from Ruby RE ambiguous arguments (#315)
108
+ * Updated gem dependencies (#311, #313)
109
+
110
+ 1.5.2
111
+ -----
112
+ * Disable calls to `eager_load_namespaces` < Rails 5 (#263)
113
+
114
+ 1.5.1
115
+ -----
116
+
117
+ * Improved < Ruby 2.3 support (#239)
118
+ * Squashed once and for all the horizontal vs vertical orientation bugs (#241)
119
+ * Added option for specifying spline types (#242)
120
+ * Added a check for Graphviz installation before building out object graph (#248)
121
+ * Fixed a bug in auto-generation rake task (#252)
122
+ * `--cluster` option will work more reliably now! (#253)
123
+ * Because it is 2017, we added Rails 5 to our official test matrix (#254)
124
+ * Fixed a bug in `--only` that prevented it from working reliably (#257)
125
+ * Added eager loading across all namespaces in the app (#258)
126
+ * Minor improvements to tests (#228)
127
+
128
+ 1.5.0
129
+ -----
130
+ * New option of 'clustering' by namespace (#205)
131
+ * Support for 'only_models_include_depth' option (#219)
132
+ * Added basic support for non-Rails apps (#208)
133
+ * Avoid duplicate specializations when using STI with an abstract base class (#211)
134
+ * Fixed Ruby 2.1 deprecation warnings (#209)
135
+ * Fixes to tests (#210, #213)
136
+ * Various documentation fixes (#203, #212)
137
+
138
+ 1.4.7
139
+ -----
140
+ * Fixed grouping of associations (#190)
141
+ * Fixed issue with command line options (#198)
142
+ * Fixed horizontally graph when vertical was wanted and viceversa (#183)
143
+
144
+ 1.4.6
145
+ -----
146
+ * Revert auto-generation of diagrams added in #176 (#191)
147
+ * Fix some Ruby warnings (#187)
148
+ * Rescue from TypeError when loading target app (#185)
149
+
150
+ 1.4.5
151
+ -----
152
+
153
+ * Fix bug in `auto generate diagram` (#176)
154
+ * Protect against `nil` model names (#177, #178)
155
+
156
+ 1.4.4
157
+ -----
158
+
159
+ * Return nil if native_type is geography (#168)
160
+ * Change tests to address flickering failures on Travis-CI
161
+
162
+ 1.4.3
163
+ -----
164
+
165
+ * Fix for bug where defaults were overriding configuration options (#166)
166
+
167
+ 1.4.2
168
+ -----
169
+
170
+ * Fix for issue with strings vs symbols in options (#157)
171
+ * Fix for 'geometry' columns causing errors (#158)
172
+
173
+ 1.4.1
174
+ -----
175
+
176
+ * Improved travis-ci testing
177
+ * Improved speed of Attribute#from_model (#145)
178
+ * Fixed a long-standing bug in rake task (#149)
179
+ * Fixed 'No entities found' error when using filter (#152)
180
+ * Prevent deprecation warning by specifying test order (#153)
181
+ * Updated CODE_OF_CONDUCT
182
+
183
+ 1.4.0
184
+ -----
185
+
186
+ * Drop support for spaces in filenames (#123)
187
+ * Ensure that #generalized? could be used (#127)
188
+ * Fixing typos in font config (#140)
189
+
190
+ 1.3.1
191
+ -----
192
+
193
+ * Check that models are not abstract (#47)
194
+ * Added MIT license (#117)
195
+ * Fixed an issue with :only and :exclude options (#122)
196
+ * Added a :sort option to preserve original attribute order (#126)
197
+ * Mark primary and unique keys as such in diagram (#129)
198
+
199
+ 1.3.0
200
+ -----
201
+
202
+ * Added support for Rails 4 (Issues #120, #115, #85, #89, and #68)
203
+
204
+ 1.2.2
205
+ -----
206
+
207
+ * Fixes a bug in sorting abstract classes (Issues #54, #88)
208
+
209
+ 1.2.1
210
+ -----
211
+
212
+ * Fixes a bug in OS detection for JRuby (and newer MRI Rubies, too)
213
+
214
+ 1.2.0
215
+ -----
216
+
217
+ * Fixed bug that prevented generation of diagrams on newer versions of OSX
218
+ * Added ability to store CLI configuration options in a config file, both a global version (in the user's home directory) as well as a per-project local versions
219
+ * Added a Code of Conduct for the project
220
+
221
+ 1.1.0
222
+ -----
223
+
224
+ * Abstract models (with 'self.abstract_class = true') are now considered for
225
+ the domain and will be displayed if 'polymorphism=true'. This should also
226
+ fix errors that could occur if abstract models had any associations.
227
+ * Correctly save Graphviz diagrams with spaces in the filename (contributed by
228
+ Neil Chambers).
229
+ * Add only/exclude to CLI (contributed by Dru Ibarra).
230
+
231
+
232
+ 1.0.0
233
+ -----
234
+
235
+ * The internal API is now stable and will be backwards compatible until
236
+ the next major version.
237
+ * Added experimental command line interface (erd). The CLI still requires a
238
+ Rails application to be present, but it may one day support other kinds of
239
+ applications.
240
+ * Crow's foot notation (also known as the Information Engineering notation)
241
+ can be used by adding 'notation=crowsfoot' to the 'rake erd' command
242
+ (contributed by Jeremy Holland).
243
+ * Filter models by using the only or exclude options (only=ModelOne,ModelTwo
244
+ or exclude=ModelThree,ModelFour) from the command line (contributed by
245
+ Milovan Zogovic).
246
+ * Process column types that are unsupported by Rails (contributed by Erik
247
+ Gustavson).
248
+ * Ignore custom limit/scale attributes that cannot be converted to an integer
249
+ (reported by Adam St. John).
250
+
251
+ 0.4.5
252
+ -----
253
+
254
+ * Display more helpful error message when the application models could not be
255
+ loaded successfully by the 'rake erd' task (reported by Greg Weber).
256
+
257
+ 0.4.4
258
+ -----
259
+
260
+ * Added the ability to disable HTML markup in node labels (markup=false). This
261
+ causes .dot files to be compatible with OmniGraffle, which otherwise fails
262
+ to import graphs with HTML node labels (issue reported by Lucas Florio,
263
+ implementation based on template by Troy Anderson).
264
+ * Prevent models named after Graphviz reserved words (Node, Edge) from causing
265
+ errors in .dot files (reported by gguthrie).
266
+ * Improved error messages when Graphviz is throwing errors (reported by
267
+ Michael Irwin).
268
+
269
+ 0.4.3
270
+ -----
271
+
272
+ * Display the scale of decimal attributes when set. A decimal attribute with
273
+ precision 5 and scale 2 is now indicated with (5,2).
274
+ * Fixed deprecation warnings for edge Rails (upcoming 3.1).
275
+
276
+ 0.4.1
277
+ -----
278
+
279
+ * Fix processing of associations with class_name set to absolute module paths.
280
+ * Adjust model loading process to include models in non-standard paths eagerly.
281
+
282
+ 0.4.0
283
+ -----
284
+
285
+ * Support to optionally display single table inheritance relationships
286
+ (inheritance=true).
287
+ * Support to optionally display polymorphic associations (polymorphism=true).
288
+ * Adjustments to 'advanced' style so that it matches original Bachman style,
289
+ and therefore now called 'bachman'.
290
+ * Ignore models without tables (reported by Mark Chapman).
291
+ * Mutual indirect relationships are now combined.
292
+ * Changed API for diagram generation.
293
+ * Restructured classes and renamed several API properties and methods.
294
+ * Added new edge type to describe single table inheritance and polymorphic
295
+ associations: Specialization.
296
+ * Added compatibility for Active Record 3.1 (beta), removed dependency on Arel.
297
+ * Rubinius compatibility.
298
+
299
+ 0.3.0
300
+ -----
301
+
302
+ * Added the ability to support multiple styles of cardinality notations.
303
+ Currently supported types are 'simple' and 'advanced'.
304
+ * Added option to exclude indirect relationships (indirect=false).
305
+ * Added option to change or disable the diagram title (title='Custom title').
306
+ * Altered the type descriptions of attributes.
307
+ * Renamed options for flexibility and clarity.
308
+ * Improved internal logic to determine the cardinality of relationships.
309
+ * More versatile API that allows you to inspect relationships and their
310
+ cardinalities.
311
+ * Changed line widths to 1.0 to avoid invisible node boundaries with older
312
+ versions of Graphviz (reported by Mike McQuinn).
313
+ * Bundled examples based on actual applications.
314
+
315
+ 0.2.0
316
+ -----
317
+
318
+ * Added simple way to create your own type of diagrams with a tiny amount of code.
319
+ * Improved internal API and documentation.
320
+ * Subtle changes in diagram style.
321
+ * Fixed error where non-mutual relationships might be inadvertently classified
322
+ as indirect relationships.
323
+ * Fixed error where diagrams with a vertical layout might fail to be generated.
324
+
325
+ 0.1.1
326
+ -----
327
+
328
+ * Fixed small errors in Ruby 1.8.7.
329
+ * Abort generation of diagrams when there are no models.
330
+
331
+ 0.1.0
332
+ -----
333
+
334
+ * Released on September 20th, 2010.
335
+ * First public release.
data/LICENSE.md ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2010-2026 Voormedia B.V.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -12,7 +12,86 @@ Rails ERD was created specifically for Rails and works on versions 6.0 and later
12
12
  Preview
13
13
  -------
14
14
 
15
- Here's an example entity-relationship diagram that was generated by Rails ERD:
15
+ Since version 2.0, Rails ERD generates [Mermaid](https://mermaid.js.org/) diagrams by default, which render natively on GitHub. Here's a diagram generated from the Event Forms application — one of Rails ERD's bundled examples (the dotted lines are indirect `has_many :through` relationships):
16
+
17
+ ```mermaid
18
+ erDiagram
19
+ direction LR
20
+ Event {
21
+ boolean active
22
+ string costs
23
+ text description
24
+ string duration
25
+ text introduction
26
+ text report
27
+ string speaker
28
+ string target_audience
29
+ string title
30
+ string tutors
31
+ }
32
+ EventDate {
33
+ string date
34
+ text description
35
+ date expiry_date
36
+ string location
37
+ }
38
+ Form {
39
+ string name
40
+ }
41
+ FormField {
42
+ string field_type
43
+ string label
44
+ boolean mandatory
45
+ string name
46
+ }
47
+ FormFieldValue {
48
+ string key
49
+ string value
50
+ }
51
+ Group {
52
+ boolean active
53
+ text description
54
+ text email_message
55
+ string email_receiver
56
+ string email_subject
57
+ string title
58
+ string url_slug
59
+ }
60
+ Organization {
61
+ string domain
62
+ text email_message
63
+ string email_receiver
64
+ string email_subject
65
+ string name
66
+ string phone
67
+ string signup_title
68
+ string subdomain
69
+ string website
70
+ }
71
+ Signup {
72
+ boolean confirmed
73
+ string email
74
+ text serialized_fields
75
+ }
76
+ Stylesheet {
77
+ text content
78
+ string name
79
+ }
80
+ Organization o|--}o Stylesheet : ""
81
+ Stylesheet ||--}o Group : ""
82
+ EventDate o|--}o Signup : ""
83
+ Organization ||--}o Group : ""
84
+ Organization o|--}o Form : ""
85
+ Organization o|..}o Event : ""
86
+ Form ||--}o Group : ""
87
+ Group ||--}o Event : ""
88
+ Group o|..}o EventDate : ""
89
+ Form o|--}o FormField : ""
90
+ FormField o|--}o FormFieldValue : ""
91
+ Event ||--}o EventDate : ""
92
+ ```
93
+
94
+ Rails ERD can also produce richly styled diagrams with Graphviz (PDF/PNG/SVG):
16
95
 
17
96
  ![Entity-Relationship Diagram](https://voormedia.github.io/rails-erd/images/entity-relationship-diagram.png)
18
97
 
@@ -43,7 +122,7 @@ This generates a Mermaid diagram (`erd.mmd`) by default. Mermaid diagrams render
43
122
 
44
123
  * Add `gem 'ruby-graphviz'` to your Gemfile
45
124
 
46
- * Run `bundle exec erd generator=graphviz filetype=pdf`
125
+ * Run `bundle exec erd --generator=graphviz --filetype=pdf`
47
126
 
48
127
  ### Configuration
49
128
 
@@ -70,6 +149,7 @@ sort: true
70
149
  warn: true
71
150
  title: true
72
151
  exclude: null
152
+ exclude_attributes: null
73
153
  only: null
74
154
  only_recursion_depth: null
75
155
  prepend_primary: false
@@ -77,6 +157,122 @@ cluster: false
77
157
  splines: spline
78
158
  ```
79
159
 
160
+ ### Hiding attributes for specific models
161
+
162
+ While `attributes: false` hides attributes for *every* model, `exclude_attributes`
163
+ lets you hide attributes for individual models without affecting the others. Map a
164
+ model name to `true` to hide all of its attributes, or to a list of attribute names
165
+ to hide only those:
166
+
167
+ ```yaml
168
+ exclude_attributes:
169
+ BigTable: true # hide all attributes for BigTable
170
+ User: # hide only these attributes for User
171
+ - password_digest
172
+ - remember_token
173
+ ```
174
+
175
+ From the command line, pass a comma separated list where each entry is either
176
+ `Model` (hide all of its attributes) or `Model.attribute` (hide a single one):
177
+
178
+ ```bash
179
+ # rake task (bare key=value)
180
+ bundle exec rake erd exclude_attributes="BigTable,User.password_digest,User.remember_token"
181
+
182
+ # erd binary (flags require the -- prefix)
183
+ bundle exec erd --exclude_attributes="BigTable,User.password_digest,User.remember_token"
184
+ ```
185
+
186
+ ### Filtering models with exclude and only
187
+
188
+ Use `exclude` to hide specific models from the diagram, or `only` to show only
189
+ specific models. Both options support three pattern types:
190
+
191
+ **Exact match** — the model name must match exactly (backward compatible):
192
+
193
+ ```yaml
194
+ exclude:
195
+ - AdminUser
196
+ - AuditLog
197
+ ```
198
+
199
+ **Glob patterns** — use `*` to match any characters, `?` for a single character,
200
+ or `[...]` for character classes. This is useful for excluding entire namespaces:
201
+
202
+ ```yaml
203
+ exclude:
204
+ - "SolidQueue::*" # all SolidQueue models (13+ tables)
205
+ - "Blazer::*" # all Blazer models
206
+ - "ActiveStorage::*" # all ActiveStorage models
207
+ - "Ahoy::*" # all Ahoy analytics models
208
+
209
+ only:
210
+ - "MyApp::*" # show only models in MyApp namespace
211
+ ```
212
+
213
+ **Regex patterns** — wrap the pattern in `/slashes/` for regular expression
214
+ matching. Supports `i` (case-insensitive), `m` (multiline), and `x` (extended) flags:
215
+
216
+ ```yaml
217
+ exclude:
218
+ - "/^Active/" # models starting with "Active"
219
+ - "/Queue$/i" # models ending with "Queue" (case-insensitive)
220
+ - "/(Audit|Log)/" # models containing "Audit" or "Log"
221
+ ```
222
+
223
+ You can mix pattern types in the same configuration:
224
+
225
+ ```yaml
226
+ exclude:
227
+ - "SolidQueue::*" # glob: entire namespace
228
+ - "/^Active/" # regex: prefix match
229
+ - InternalTool # exact: specific model
230
+ ```
231
+
232
+ **Notes:**
233
+
234
+ - Patterns with `*` should be quoted in YAML to avoid parsing issues
235
+ - Invalid regex patterns will raise an error — test your patterns first
236
+ - Only `i`, `m`, `x` regex flags are supported; other flags are ignored
237
+ - When both `exclude` and `only` are specified, `only` is applied first, then `exclude`
238
+
239
+ ### Grouping models by namespace
240
+
241
+ Use `cluster: true` to visually group models by their Ruby namespace. This is
242
+ especially useful for large applications with many namespaced models.
243
+
244
+ **With Graphviz output**, clustering creates subgraph boxes around each namespace:
245
+
246
+ ```bash
247
+ bundle exec erd --generator=graphviz --cluster=true
248
+ ```
249
+
250
+ **With Mermaid `classDiagram` output**, clustering uses Mermaid's native namespace blocks:
251
+
252
+ ```bash
253
+ bundle exec erd --mermaid_style=classdiagram --cluster=true
254
+ ```
255
+
256
+ This produces output like:
257
+
258
+ ```mermaid
259
+ classDiagram
260
+ namespace Admin {
261
+ class User
262
+ class Role
263
+ }
264
+ namespace Billing {
265
+ class Invoice
266
+ class Payment
267
+ }
268
+ User --> Role
269
+ Invoice --> Payment
270
+ ```
271
+
272
+ **Note:** Clustering is not supported with Mermaid's default `erDiagram` style
273
+ (ER diagrams don't have a namespace concept). If you need clustering with Mermaid,
274
+ use `mermaid_style: classdiagram`.
275
+
80
276
  You can also customize fonts (useful if the defaults aren't available on your system):
81
277
 
82
278
  ```yaml
@@ -95,7 +291,7 @@ filename: docs/erd
95
291
  Or via command line:
96
292
 
97
293
  ```bash
98
- bundle exec erd filename="docs/erd"
294
+ bundle exec erd --filename="docs/erd"
99
295
  ```
100
296
 
101
297
  Mermaid output (default)
@@ -106,7 +302,7 @@ Rails ERD generates [Mermaid](https://mermaid.js.org/) diagrams by default. Merm
106
302
  By default, Mermaid output uses `erDiagram` syntax with crow's foot notation, PK/FK markers, and proper cardinality. You can switch to `classDiagram` syntax if preferred:
107
303
 
108
304
  ```bash
109
- bundle exec erd mermaid_style=classdiagram
305
+ bundle exec erd --mermaid_style=classdiagram
110
306
  ```
111
307
 
112
308
  Or in your `.erdconfig`:
@@ -131,13 +327,32 @@ erDiagram
131
327
  Organization ||--o{ User : ""
132
328
  ```
133
329
 
330
+ tbls JSON output
331
+ ----------------
332
+
333
+ Rails ERD can emit a JSON description of your domain in the
334
+ [tbls](https://github.com/k1LoW/tbls) schema format. Unlike a `schema.rb`
335
+ dump, this output captures the relationships Rails ERD derives from
336
+ ActiveRecord — so `belongs_to` associations show up as foreign keys even
337
+ when the database has no FK constraint.
338
+
339
+ Any tbls-compatible tool can consume the resulting file. For example, to
340
+ render an interactive ERD with [Liam ERD](https://liambx.com):
341
+
342
+ ```bash
343
+ bundle exec erd --generator=tbls
344
+ # writes erd.json
345
+
346
+ npx @liam-hq/cli erd build --input erd.json --format tbls
347
+ ```
348
+
134
349
  Graphviz output
135
350
  ---------------
136
351
 
137
352
  For PDF, PNG, or SVG output, you can use the Graphviz generator:
138
353
 
139
354
  ```bash
140
- bundle exec erd generator=graphviz filetype=pdf
355
+ bundle exec erd --generator=graphviz --filetype=pdf
141
356
  ```
142
357
 
143
358
  This requires:
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ Rake::TestTask.new do |test|
9
9
  end
10
10
 
11
11
  YARD::Rake::YardocTask.new do |yard|
12
- yard.files = ["lib/**/*.rb", "-", "LICENSE", "CHANGES.md"]
12
+ yard.files = ["lib/**/*.rb", "-", "LICENSE.md", "CHANGES.md"]
13
13
  end
14
14
 
15
15
  desc "Generate diagrams for bundled examples"