【问题标题】:Modeling a Poll Feature为投票特征建模
【发布时间】:2011-12-17 06:24:02
【问题描述】:

我正在开发一个投票功能,允许users 使用options 创建投票questions 并允许其他usersanswer 他们

answer 模型包含一个 option_id 列,但是这两个模型不相关。

我有两个问题:

  • 我的模型(如下)是否完全封装了我想要表示的内容?
  • answer 控制器操作的创建方法看起来如何? (具体如何找回option_id

注意:我从未处理过模型(answer)通过option_id 引用另一个模型(option)但两者不相关的模式

到目前为止,我有这个:

class Question < ActiveRecord::Base
  belongs_to :user
  has_many :options
  has_many :answers
end

class Option < ActiveRecord::Base
  belongs_to :question
end

class Answer < ActiveRecord::Base
  belongs_to :user
  belongs_to :question
end

【问题讨论】:

    标签: ruby-on-rails ruby database ruby-on-rails-3 database-design


    【解决方案1】:

    找到一个tut 用于执行此操作的移动应用

    【讨论】:

      猜你喜欢
      • 2010-11-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-29
      相关资源
      最近更新 更多