Sha256: 0b25781b62be0fd4857da17b53f6a7849b457629ef010650cea4ca7ab6d92c54
Contents?: true
Size: 1017 Bytes
Versions: 2
Compression:
Stored size: 1017 Bytes
Contents
class Admin::CommentsController < AdminController before_action :set_article, only: [:index, :show, :edit, :update] before_action :set_comment, only: [:show, :edit, :update] def index skope = Comment.where article_id: @article.id @comments = skope.order("created_at ASC").paginate page: params[:page], per_page: 5 @count = skope.count end def show render end def edit render end def update if @comment.update comment_params emit @comment, :updated, data: {article_id: @article.id} render json: {success: true, status: 200, flash: {success: 'Comment updated!'}, data: {}} else render json: {success: false, status: 400, errors: @comment.errors} end end private def comment_params params.require(:comment).permit :author, :text, :emotion, :pinned, :admin_rate end def set_article @article = Article.find params[:article_id] end def set_comment @comment = @article.comments.find params[:id] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
loco-rails-3.0.5 | test/dummy/app/controllers/admin/comments_controller.rb |
loco-rails-3.0.4 | test/dummy/app/controllers/admin/comments_controller.rb |