Guest User

Untitled

a guest
Jan 19th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #this does work, but i do not know if the push fails
  2. def create
  3. comment = Comment.new(:text => params[:text])
  4. @item.comments << comment
  5. render :text => comment
  6. end
  7.  
  8. #this does not work
  9. def create
  10. comment = Comment.new(:text => params[:text])
  11. if @item.comments << comment
  12. render :text => comment
  13. else
  14. render :text => 'oh no'
  15. end
  16. end
  17.  
  18. #this does not work
  19. def create
  20. begin
  21. comment = Comment.new(:text => params[:text])
  22. @item.comments << comment
  23. render :text => comment
  24. rescue Exception => e
  25. render :text => 'oh no'
  26. end
  27. end
  28.  
  29. def create
  30. comment = Comment.new(:text => params[:text])
  31. comment.item = @item
  32. if comment.save
  33. render :text => "yay"
  34. else
  35. render :text => "oh no"
  36. end
  37. end
Add Comment
Please, Sign In to add comment