title: Render validation error messages on the page for partial forms
body: <p>I have a bug show/edit form, which contains partials to add comments and attachment.</p>
  
  <p>When a user tries to submit invalid attachment type or an empty comment, the validation would throw an error <code>[validates :comment, presence: true]</code> and similar for attachment[<code>using paperclip gem</code>], now when this happens, I want the error messages to be displayed on the same bug form. </p>
  
  <p>The repo is at @ <a href="https://github.com/hsdqa/bugtracker" rel="nofollow" title="Github Repo Source">GitHub Link</a></p>
  
  <p>In my show form I have </p>
  
  <pre><code>show.html.erb
  &lt;%= render partial: 'bug_attachments/bug_form' %&gt;
  &lt;%= render partial: 'comments/form' %&gt;
  
  comments/form.html.erb
  &lt;% @comment = Comment.new %&gt;
  &lt;%= form_for [@bug, @comment] do |f| %&gt;
  &lt;%= f.text_area :body, placeholder: "Add a comment" %&gt;
  &lt;%= f.submit 'Add Comment'%&gt;
  &lt;% end %&gt;
  
  
  comments_controller.rb
  class Bugs::CommentsController &lt; ApplicationController
  before_action :authenticate_user!
  before_action :set_bug
  
  def create
    @comment = @bug.comments.new comment_params
    @comment.user = current_user
    if @comment.save
      redirect_to bug_path(@comment.bug_id), notice: 'Comment added successfully'
    else
      # Here I am setting @bug = 1 since when the user posts the comments, the @bug becomes nil.
      @bug = Bug.find(1)
      render 'bugs/show'
      # redirect_to @comment, alert: 'Unable to save your comment'
    end
   end
   private
    def set_bug
     @bug = Bug.find(params[:bug_id])
    end
    def comment_params
     params.require(:comment).permit(:body)
   end
  end
  </code></pre>
  
  <p>Any help here please?</p>