Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unable to display validation error from a partial form
- %html
- %head
- %title= @post.title
- %body
- %h2 Create Comments:
- = form_for([@post, @post.comments.build]) do |f|
- - if @post.errors.any? # <--- 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
- 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
- %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 => @post.comments
- = render :partial => "comments/form"
- if @comment.save
- format.html { redirect_to @post }
- else
- render :action => "new"
- end
Add Comment
Please, Sign In to add comment