我有嵌套的模型结构:
class Forum < ActiveRecord::Base
has_many :topics
class Topic < ActiveRecord::Base
has_many :posts
belongs_to :forum
class Post < ActiveRecord::Base
belongs_to :topic
has_many :post_links
has_many :links, ->{ uniq }, through: :post_links, dependent: :destroy
class PostLink < ActiveRecord::Base
belongs_to :post
belongs_to :link
class Link < ActiveRecord::Base
has_many :post_links
has_many :posts, ->{ uniq }, through: :post_links, dependent: :destroy
所以我想获取所有帖子中的所有链接,这些帖子位于论坛中与id = 1
相关的主题中根据本论坛的出现次数对它们进行排序。
因此,如果我在论坛中的一些帖子中{id = 1次,{10}次youtube.com
有google.com
次5次,那么我希望有类似的内容:
id,name,mentions_count
1,google.com,10
2,youtube.com,5
答案 0 :(得分:0)
.login-form-input:focus {
border:1px solid blue;
}
我假设您的链接表中有主机列