Guest User

Untitled

a guest
Jun 24th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. class ConversationsController < ApplicationController
  2. # GET /conversations
  3. # GET /conversations.xml
  4. def index
  5. @conversations = Conversation.all
  6.  
  7. respond_to do |format|
  8. format.html # index.html.erb
  9. format.xml { render :xml => @conversations }
  10. end
  11. end
  12.  
  13. # GET /conversations/1
  14. # GET /conversations/1.xml
  15. def show
  16. @conversation = Conversation.find(params[:id])
  17.  
  18. respond_to do |format|
  19. format.html # show.html.erb
  20. format.xml { render :xml => @conversation }
  21. end
  22. end
  23.  
  24. # GET /conversations/new
  25. # GET /conversations/new.xml
  26. def new
  27. @conversation = Conversation.new
  28. @comment = @conversation.comments.build
  29.  
  30. respond_to do |format|
  31. format.html # new.html.erb
  32. format.xml { render :xml => @conversation }
  33. end
  34. end
  35.  
  36. # GET /conversations/1/edit
  37. def edit
  38. @conversation = Conversation.find(params[:id])
  39. end
  40.  
  41. # POST /conversations
  42. # POST /conversations.xml
  43. def create
  44. @conversation = Conversation.new(params[:conversation])
  45. @comment = @conversation.comments.build
  46. @comment.body = params[:body]
  47. @comment.user_id = current_user.id
  48. logger.debug 'lgaon longa longa logan' +@comment.body
  49.  
  50. respond_to do |format|
  51. if @conversation.save && $comment.save
  52. format.html { redirect_to(@conversation, :notice => 'Conversation was successfully created.') }
  53. format.xml { render :xml => @conversation, :status => :created, :location => @conversation }
  54. else
  55. format.html { render :action => "new" }
  56. format.xml { render :xml => @conversation.errors, :status => :unprocessable_entity }
  57. end
  58. end
  59. end
  60.  
  61. # PUT /conversations/1
  62. # PUT /conversations/1.xml
  63. def update
  64. @conversation = Conversation.find(params[:id])
  65.  
  66. respond_to do |format|
  67. if @conversation.update_attributes(params[:conversation])
  68. format.html { redirect_to(@conversation, :notice => 'Conversation was successfully updated.') }
  69. format.xml { head :ok }
  70. else
  71. format.html { render :action => "edit" }
  72. format.xml { render :xml => @conversation.errors, :status => :unprocessable_entity }
  73. end
  74. end
  75. end
  76.  
  77. # DELETE /conversations/1
  78. # DELETE /conversations/1.xml
  79. def destroy
  80. @conversation = Conversation.find(params[:id])
  81. @conversation.destroy
  82.  
  83. respond_to do |format|
  84. format.html { redirect_to(conversations_url) }
  85. format.xml { head :ok }
  86. end
  87. end
  88. end
Add Comment
Please, Sign In to add comment