Note that there are some explanatory texts on larger screens.

plurals
  1. POunable to display validation error from a partial form
    primarykey
    data
    text
    <p>im not able to display the validation error, even though it is validating the form. In my partial form </p> <ul> <li>if @post.errors.any?</li> </ul> <p>seems to be the problem, the @post returns a false for error and so no error is displayed. but the @comment returns a true for error, but im not able to replace @post with @comment since it throws an undefined 'comment' error.. </p> <p>my partial form which is begin called inside the show:</p> <pre><code>%html %head %title= @post.title %body %h2 Create Comments: = form_for([@post, @post.comments.build]) do |f| - if @post.errors.any? # &lt;--- Unsure what to do here.. #error_explanation %h2 = pluralize(@post.errors.count, "error") prohibited this cart from being saved: %ul - @post.errors.full_messages.each do |msg| %li= msg = f.label :Name %br = f.text_field :name %br %br = f.label :Text %br = f.text_area :text %br %br = f.submit </code></pre> <p>my comments controller:</p> <pre><code>def create @post = Post.find(params[:post_id]) @comment = @post.comments.build(params[:comment]) respond_to do |format| if @comment.save format.html { redirect_to @post } else format.html { redirect_to @post } end end end </code></pre> <p>this is show page from which im rendering the file:</p> <pre><code>%html %head %title= @post.title %body %strong Author name: = @post.author_name %br %br %strong Title: = @post.title %br %br %strong Email: = @post.email %br %br %strong Description: = @post.description %h2 Comments for this Post: = render :partial =&gt; @post.comments = render :partial =&gt; "comments/form" </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload