私は小さな(初心者の)問題にぶつかっています。
質問とレビューの2つのモデルがあります。
レビュースキーマ:question_id、user_id、rating、comments
'show'ビューで、次のフォームを統合しました(formtastic):
- semantic_form_for @question.reviews.build do |f|
= f.error_messages
= f.input :rating
= f.input :comments
= f.buttons
私のレビューコントローラーの作成アクションは次のようになります。
def create
@review = Review.new(params[:review])
@review.user_id = current_user.id
if @review.save
flash[:notice] = "Successfully created review."
redirect_to(@review.question)
else
redirect_to(@review.question)
end
end
ただし、今では、question_idフィールドに質問IDが保存されていないように見えます。user_idをうまく保存します。
誰かが私が間違っていることの手がかりを持っていますか?ログが必要な場合は、私に知らせてください!前もって感謝します