Class: CommentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
# File 'app/controllers/comments_controller.rb', line 15

def create
  @comment = Comment.new(params[:comment])
  @comment.post_id = Post.find(params[:post_id]).id
  @comment.save
end

#indexObject



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

def index
  @comments = Comment.all
  respond_to do |format|
    format.html # index.html.erb
  end
end

#showObject



3
4
5
6
7
8
# File 'app/controllers/comments_controller.rb', line 3

def show
  @comment = Comment.find(params[:id])
  respond_to do |format|
    format.html # index.html.erb
  end
end