test/dummy/app/controllers/user/comments_controller.rb in loco-rails-1.4.0 vs test/dummy/app/controllers/user/comments_controller.rb in loco-rails-1.5.0

- old
+ new

@@ -17,11 +17,14 @@ end def update if @comment.update_attributes comment_params emit @comment, :updated, data: {article_id: @article.id} - redirect_to edit_user_article_url(@article), notice: "Comment has been updated." + respond_to do |f| + f.json{ render json: {ok: true, id: @comment.id} } + f.html{ redirect_to edit_user_article_url(@article), notice: "Comment has been updated." } + end else render :edit end end @@ -32,16 +35,20 @@ end private def comment_params - params.require(:comment).permit :author, :text + permitted_params = [:author, :text] + if current_admin + permitted_params << :approved + end + params.require(:comment).permit *permitted_params end def set_article @article = current_user.articles.find params[:article_id] end def set_comment @comment = @article.comments.find params[:id] end -end \ No newline at end of file +end