Class: CommentsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/comments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
# File 'app/controllers/comments_controller.rb', line 9

def create
  @comment.user_id = current_user.id
  @comment.date_created = DateTime.now
  if @comment.save
    respond_with @comment do |format|
      format.html { redirect_to resource }
    end
  end
end

#destroyObject



19
20
21
22
23
24
# File 'app/controllers/comments_controller.rb', line 19

def destroy
  @comment.destroy
  respond_with @comment do |format|
    format.html { redirect_to resource }
  end
end

#resourceObject



26
27
28
# File 'app/controllers/comments_controller.rb', line 26

def resource
  @resource ||= @comment.resource
end