29
Có cách nào để tìm hiểu xem mô hình kết hợp là gì? Mất 2 mô hình sau đây:phương pháp đường ray để có được tên liên kết của một mô hình
class Comment < ActiveRecord::Base
belongs_to :commentable
end
class Post < ActiveRecord::Base
has_many :comments
belongs_to :user
end
Tôi đang tìm một cái gì đó như:
Post.has_many #=> ['comments', ...]
Post.belongs_to # => ['user']
Comment.belongs_to # => ['commentable']
Hoàn hảo! Cảm ơn. – DiegoSalazar