Twitterで実装されているアンケート機能をRuby on Railsで作ろうとしているのですが、データの表示が出来なくて困っているので質問させていただきます。
Userモデル
Questionモデル => title, user_id
Pollモデル(中間) => question_id, choice_id
Choiceモデル => content, question_id
class QuestionsController < ApplicationController def index @questions = Question.all end ... ... end
# index.html.haml - @questions.each do |question| %li = question.user.name = question.title = question.choice.content
エラーメッセージ
undefined method `choice' for
どのようにしてchoicesテーブルのcontentカラムを表示するのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/12/17 17:35