Guest User

Untitled

a guest
May 27th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. ## view / form
  2. # form_remote_tag is posted before this code.
  3. <table>
  4. <tr>
  5. <td class='CommentColumn'></td>
  6. <td id='Loading<%=elements.id%>'
  7. style='display : none; font-weight : bold; text-align : center;
  8. width : 270px;'>Loading</td>
  9. </tr>
  10.  
  11. <tr>
  12. <td class='CommentColumn'></td>
  13. <td id='CommentResponse<%=elements.id%>'
  14. style='font-weight : bold; text-align : center;
  15. width : 270px;'></td>
  16. </tr>
  17.  
  18. <tr>
  19. <td class='CommentColumn'>Subject :</td>
  20. <td><%=text_field "comments", "name", { :class => 'form' } %>
  21. </tr>
  22.  
  23. <tr>
  24. <td class='CommentColumn'>Name/Alias :</td>
  25. <td><%=text_field "comments", "title", { :class => 'form' } %>
  26. </tr>
  27.  
  28. <tr>
  29. <td class='CommentColumn' valign="top">Comment :</td>
  30. <td><%= text_area "comments", "comment", { :class => 'CommentTextArea' } %>
  31. </tr>
  32.  
  33. <%= hidden_field "comments", "blogid", { :value => elements.id } %>
  34. <tr>
  35. <td>&nbsp;</td>
  36. <td> <%= submit_tag "Post ya comment!" %> </td>
  37. </tr>
  38.  
  39. </table>
  40. ## model
  41. class Comments < ActiveRecord::Base
  42. validates_presence_of :name
  43. validates_presence_of :title
  44. validates_presence_of :comment
  45. end
  46.  
  47. ## view that is rendered after ajax request
  48. hi
  49. <%= error_messages_for 'Comments' %>
  50.  
  51. ## controller
  52.  
  53. def postcomment
  54. @comment = Comments.new( params[:comments])
  55. if @comment.valid?
  56. # render page..
  57. else
  58. render :partial => 'users/themes/geek/comments_error.html.erb'
  59. end
  60. end
Add Comment
Please, Sign In to add comment