Class: Blogaze::Controllers::Admin::Comments

Inherits:
Controller show all
Defined in:
lib/blogaze/controllers/admin/comments.rb

Instance Method Summary collapse

Methods inherited from Controller

#initialize

Methods inherited from Controller

#get_settings, #initialize, #title, #view_file

Constructor Details

This class inherits a constructor from Blogaze::Controllers::Admin::Controller

Instance Method Details

#approve(comment_id) ⇒ Object

Approve comment

Parameters:

  • comment_id (Integer)


29
30
31
32
33
# File 'lib/blogaze/controllers/admin/comments.rb', line 29

def approve(comment_id)
  ::Blogaze::Models::Comment[comment_id].update(:in_moderation => 0).save
  flash[:success] = "Comment approved"
  redirect r('/')
end

#delete(comment_id) ⇒ Object

Delete comment

Parameters:

  • comment_id (Integer)


40
41
42
43
44
# File 'lib/blogaze/controllers/admin/comments.rb', line 40

def delete(comment_id)
  ::Blogaze::Models::Comment[comment_id].delete
  flash[:success] = "Comment deleted"
  redirect r('/')
end

#indexObject

List comments



18
19
20
21
22
# File 'lib/blogaze/controllers/admin/comments.rb', line 18

def index
  title "Comments"
  @comments = ::Blogaze::Models::Comment.all
  respond(view_file('admin/comments/index'))
end