I created a sample Rails app. I generated two models, A and B, and a relationship model called Rel.
Then I added a many-to-many association between A and B using has_many :through, which connects A and B via the Rel model.
Here's some code:
# models/a.rb
class A < ActiveRecord::Base
has_many :rels
has_many :bs, through: :rels
end
# models/b.rb
class B < ActiveRecord::Base
has_many :rels
has_many :as, through: :rels
end
# db/migrate/xxx_create_rels.rb
class CreateRels < ActiveRecord::Migration
def change
create_table :rels do |t|
t.belongs_to :a, index: true
t.belongs_to :b, index: true
t.timestamps
end
end
end
When using rails-erd, I expect to get a many-to-many indirect (as stated on the docs) association between A and B, which means a dotted line with arrows at both ends between A and B (as if I used HABTM), and a solid line with between A and Rel and between B and Rels with an arrow pointing to Rel (being a one-to-many association).
Here's what I get:
The dotted line points from A to B, while A and B join the association in a perfectly symmetric way.
Issue by whatyouhide Sunday Feb 09, 2014 at 15:16 GMT Originally opened as https://github.com/voormedia/rails-erd/issues/67
I created a sample Rails app. I generated two models, A and B, and a relationship model called Rel. Then I added a many-to-many association between A and B using
has_many :through
, which connects A and B via the Rel model. Here's some code:When using
rails-erd
, I expect to get a many-to-many indirect (as stated on the docs) association between A and B, which means a dotted line with arrows at both ends between A and B (as if I used HABTM), and a solid line with between A and Rel and between B and Rels with an arrow pointing to Rel (being a one-to-many association).Here's what I get:
The dotted line points from A to B, while A and B join the association in a perfectly symmetric way.