Class: Storytime::CommentsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user!, #current_user, #setup, #user_signed_in?

Methods included from Storytime::Concerns::CurrentSite

#current_storytime_site

Methods included from Storytime::Concerns::ControllerContentFor

#content_for, #content_for?, #view_context

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
# File 'app/controllers/storytime/comments_controller.rb', line 12

def create
  @comment = Comment.new(comment_params)
  @comment.user = current_user
  @comment.post = @post

  authorize @comment
  opts = { notice: I18n.t('flash.comments.create.success') } if @comment.save
  redirect_to @post, opts
end

#destroyObject



22
23
24
25
26
27
# File 'app/controllers/storytime/comments_controller.rb', line 22

def destroy
  @comment = current_user.storytime_comments.find(params[:id])
  authorize @comment
  @comment.destroy
  respond_with @comment
end