I
I
Ilnar252015-04-29 20:15:57
Ruby on Rails
Ilnar25, 2015-04-29 20:15:57

What is the correct way to organize a tree structure in Rails4?

Hi all!
I started learning ruby ​​on rails recently, so I'm stating my question in the light of what I've learned. Task from one vacancy:
You need to create a blog.
There are 3 models Comment, Post, Category. Comment and Post organized simply through post_id. Somewhere I read information that an excessive hierarchy destroys the speed of a request, and now it does not leave me alone for a day. Is it worth it to add a category_id to the Post model (more precisely, to the migration file) and continue working, or is there a gem and possibly another implementation? According to the conditions and Category should be organized in a tree structure (it's not entirely clear to me how they do it). Enlighten who can. Thank you!

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Andrey Andreev, 2015-04-29
@b0nn1e

You should at least fully voice the task, and not your guesses, but in general you are here - rusrails.ru/active-record-associations

T
tpepost, 2015-04-30
@tpepost

Don't invent a bicycle. Use https://github.com/stefankroes/ancestry

L
Lesha Fedoseev, 2015-04-29
@alexfedoseev

And even better here:
https://www.railstutorial.org/book
railstutorial.ru

I
Ilnar25, 2015-04-29
@Ilnar25

Thank you!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question