Comments (3)
I think your main problem comes from overusing single table inheritance.
Is an album, photo or comment really a post?
It seems like these entities have very different attributes and would benefit from being modeled in their own tables.
Your Post class would then look like this:
class Post
has_many :comments
has_many :photos
end
Then perhaps only the comments model warrants acts_as_tree.
(Updated: the prior response was voice transcribed and garbled).
from closure_tree.
@mceachen I've already said that I'm doing something weird, for some reason.
The question keeps if I can create 2 trees of children for a node...
from closure_tree.
You can add a where constraint on the children or descendants scopes, and expose those as other attributes.
class Post
def child_comments
children.where(:type => "Comments")
end
end
from closure_tree.
Related Issues (20)
- What should I do when my data volume is very large, more than 100 million? HOT 3
- easiest way to move element within list? HOT 3
- How can I migrate 3 million data to hierarchy table?
- N + 1 feedback
- Determinstic ordering using a second column if the value of the first is null
- `parent_id` as zero HOT 1
- Postgres 12 + Rails 6.1: RETURNING "id" issue HOT 1
- Hierarchy model inheritance breaks usage with STI and superclass validations HOT 1
- Regression in combination with paper_trail gem HOT 5
- Deferred hierachy rebuild
- Self-referential model breaks `#ancestors` method. HOT 1
- Children Not Destroyed on call.
- reason for with_ancestor method using map HOT 2
- Fix compound unique index for template in hierarchies_table HOT 4
- Dirty tracking lost when setting parent with numeric_order option HOT 1
- Could there be an option for with_ancestor to include ancestors?
- Loss of namespace when using Accessing Data methods HOT 1
- SystemStackError when updating fixtures HOT 1
- parallel_test fails HOT 2
- Usage with STI table HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from closure_tree.