Class: SofaBlog::Admin::CommentsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/sofa_blog/admin/comments_controller.rb

Instance Method Summary collapse

Instance Method Details

#approveObject



47
48
49
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 47

def approve
  @comment.approve!
end

#createObject



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

def create
  @comment.save!
  flash[:notice] = 'Comment created'
  redirect_to :action => :index
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to create Comment'
  render :action => :new
end

#destroyObject



41
42
43
44
45
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 41

def destroy
  @comment.destroy
  flash[:notice] = 'Comment removed'
  redirect_to :action => :index
end

#disapproveObject



51
52
53
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 51

def disapprove
  @comment.disapprove!
end

#editObject



28
29
30
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 28

def edit
  render
end

#indexObject



7
8
9
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 7

def index
  @comments = SofaBlog::Comment.order('created_at DESC')
end

#newObject



15
16
17
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 15

def new
  render
end

#showObject



11
12
13
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 11

def show
  render
end

#updateObject



32
33
34
35
36
37
38
39
# File 'app/controllers/sofa_blog/admin/comments_controller.rb', line 32

def update
  @comment.update_attributes(params[:comment])
  flash[:notice] = 'Comment updated'
  redirect_to :action => :index
rescue ActiveRecord::RecordInvalid
  flash.now[:error] = 'Failed to update Comment'
  render :action => :edit
end