0

何が起こったのかわかりませんが、質問フォームが機能しなくなり、送信後に空白になります。

フォームビューは次のとおりです。

<%= simple_form_for [@comment, Question.new] do |f| %>
<p>
<div class="form">
<%= f.input :title, as: :text, input_html: { rows: "1" } %>
<%= f.input :body, as: :text, input_html: { rows: "10" } %>

<p><%= f.submit "Answer", class: "btn btn-primary" %></p>
</div>
<% end %>

質問モデル:

class Question < ActiveRecord::Base
validates :body, presence: true
validates :title, presence: true
validates :user_id, presence: true

belongs_to :user
acts_as_votable
belongs_to :comment
has_many :pictures

end

そしてコントローラー:

 def create
 @comment = Comment.find(params[:comment_id])
 @question = @comment.questions.create(question_params)

 respond_to do |format|
  if @question.save
  format.html { redirect_to comment_questions_path, notice: 'Question was successfully created.' }  
    format.json { render action: 'show', status: :created, location: comment_questions_path }
  else
    format.html { render action: 'new' }
    format.json { render json: @question.errors, status: :unprocessable_entity }
  end
 end
end
4

1 に答える 1