【发布时间】:2012-03-03 18:50:09
【问题描述】:
我刚刚在我的数据库中为我的 micropost 表创建了新列,这些列是 vote_count comment_count,我想将它连接到投票模型 vote_up 计数和评论模型评论计数。由于我只是添加了这些列,尽管有投票和 cmets,我如何将这些其他模型连接到 micropost 模型以填充新列。任何建议都非常感谢!
微博模型
class Micropost < ActiveRecord::Base
attr_accessible :title, :content, :view_count
acts_as_voteable
belongs_to :school
belongs_to :user
has_many :comments
has_many :views
accepts_nested_attributes_for :comments
end
【问题讨论】:
标签: ruby-on-rails database ruby-on-rails-3 associations rails-activerecord