Class: Tenon::CommentsController
- Inherits:
-
ResourcesController
- Object
- ApplicationController
- BaseController
- ResourcesController
- Tenon::CommentsController
- Defined in:
- app/controllers/tenon/comments_controller.rb
Instance Method Summary collapse
Methods inherited from ResourcesController
#create, #destroy, #edit, #initialize, #new, #reorder, #update
Constructor Details
This class inherits a constructor from Tenon::ResourcesController
Instance Method Details
#index ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'app/controllers/tenon/comments_controller.rb', line 5 def index respond_to do |format| format.html do @counts = { all: Tenon::Comment.count, approved: Tenon::Comment.approved.count, unapproved: Tenon::Comment.unapproved.count } end format.json do @comments = Tenon::Comment.all @comments = @comments.where(search_args) if params[:q] if %w(approved unapproved).include?(params[:type]) @comments = @comments.send(params[:type]) end @comments = @comments.paginate(per_page: 20, page: params[:page]) @comments = Tenon::PaginatingDecorator.decorate(@comments) end end end |
#toggle_approved ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'app/controllers/tenon/comments_controller.rb', line 26 def toggle_approved respond_to do |format| if @comment.toggle_approved! format.json { render json: @comment.to_json } format.html { flash[:notice] = 'Comment approved.' and redirect_to comments_path } else format.json { render status: 500, nothing: true } format.html { flash[:warning] = 'Error approving comment.' and redirect_to comments_path } end end end |