Sha256: c4ecd663122493037039f1cf67d827d998240b0e1a907716e94adfd9049febef
Contents?: true
Size: 1 KB
Versions: 26
Compression:
Stored size: 1 KB
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_attributes 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
26 entries across 26 versions & 1 rubygems