[Rails] Active Record Relations and Nesting
Hello,
I am looking to create a rails app that will model and display
related nodes. I am just beginning to dive into active record and I
was wondering if the following pesudo code would work?
class NodeLink < ActiveRecord::Base
belongs_to :node # foreign key - node_id (recorded as
primary_node_id)
belongs_to :node # foreign key - node_id (recorded as
secondary_node_id)
end
class Node < ActiveRecord::Base
has_many :nodes, :through => :node_links
end
In essence this would create something that looks like the following.
[Node One]
| |
| |
[Node Two] [Node Three]
|
|
[Node Four]
Where the node links are represented by the lines and the nodes
themselves are enclosed in brackets. And this pattern could be
continued indefinite through different variations of nodes and links.
Any help or advice you could give would be great.
Thanks,
Devin Morin
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home