Guest User

Untitled

a guest
Jul 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. ####_Ajax_form.html
  2.  
  3. <table>
  4. <% @comment = Comment.new
  5. #@comment.link=@link
  6.  
  7. %>
  8. <% remote_form_for([@link,@comment]) do |f| %>
  9. <tr>
  10. <td><label for="comment_name" >Name</label></td>
  11. <td><%= f.text_field :name %></td>
  12. </tr>
  13.  
  14. <tr>
  15. <td><label for="comment_email" >Email (optional)</label></td>
  16. <td><%= f.text_field :email %></td>
  17. </tr>
  18.  
  19. <tr>
  20. <td><label for="comment_comment" /></td>
  21. <td><%= f.text_area :comment %></td>
  22. </tr>
  23.  
  24. <tr>
  25. <td></td>
  26. <td><%= f.submit "Create" %><td>
  27. </tr>
  28. <% end %>
  29.  
  30.  
  31. ######## Controller : comments_controller
  32.  
  33. def create
  34.  
  35. @tempComment = params[@comment]
  36. @comment = Comment.new
  37.  
  38. @comment.comment =@tempComment.comment
  39. #@comment.link=@link
  40.  
  41. #if verify_recaptcha
  42. if @comment.save
  43. respond_to do |format|
  44. format.html do
  45. flash[:notice] = 'Comment was successfully created.'
  46. redirect_to link_path(@link)
  47. end
  48. format.js do
  49. render :update do |page|
  50. page.insert_html :bottom, 'comments', :partial =>'links/comments',:locals => { :comment => @comment }
  51. page.visual_effect :highlight, 'comments'
  52. end
  53. end
  54. end
  55. else
  56. format.html { render :action => "new" }
  57. end
  58. end
Add Comment
Please, Sign In to add comment