Rails pertenece a muchos modelos [cerrado]
Encontré algunas preguntas sobre SO sobre las asociaciones de Rails que se parecen a mi pregunta, pero por mi vida no puedo entender cómo usarlas.belongs_to
Múltiples modelos.
Aquí esta laestructura de la mesa Tengo la intención de tener:
User
id
Post
id
user_id #foreign key; a post belongs to a User aka "Who created this post"
Comment
id
user_id #foreign key; a comment belongs to a User aka "Who made this comment"
post_id #foreign key; a comment belongs to a Post aka "What post this comment is for"
Y elasociaciones:
User
has_many :posts
has_many :comments
Post
belongs_to :user
has_many :comments
Comment
belongs_to :user
belongs_to :post
¿Es este el enfoque correcto?