diff --git a/app/controllers/aspects_controller.rb b/app/controllers/aspects_controller.rb index ce21bd95d4776da3ed38ea8303d2a2f6b0518ace..73bdf8cd280956f240a9e45fb32be70eb1199e20 100644 --- a/app/controllers/aspects_controller.rb +++ b/app/controllers/aspects_controller.rb @@ -22,7 +22,7 @@ class AspectsController < ApplicationController render json: result else - render nothing: true, status: 422 + head :unprocessable_entity end end @@ -71,7 +71,7 @@ class AspectsController < ApplicationController params[:ordered_aspect_ids].each_with_index do |id, i| current_user.aspects.find(id).update_attributes(order_id: i) end - render nothing: true + head :no_content end def toggle_chat_privilege @@ -79,7 +79,7 @@ class AspectsController < ApplicationController @aspect.chat_enabled = !@aspect.chat_enabled @aspect.save - render :nothing => true + head :no_content end def toggle_contact_visibility @@ -91,7 +91,7 @@ class AspectsController < ApplicationController @aspect.contacts_visible = true end @aspect.save - render :nothing => true + head :no_content end private diff --git a/app/controllers/blocks_controller.rb b/app/controllers/blocks_controller.rb index d53ee579bc77732221ed5fff51491e66b30ee96a..aa8f43cbba37a7ed3d59c00a108a2b83133b5387 100644 --- a/app/controllers/blocks_controller.rb +++ b/app/controllers/blocks_controller.rb @@ -9,7 +9,7 @@ class BlocksController < ApplicationController disconnect_if_contact(block.person) if block.save respond_with do |format| - format.json{ render :nothing => true, :status => 204 } + format.json { head :no_content } end end @@ -17,7 +17,7 @@ class BlocksController < ApplicationController current_user.blocks.find(params[:id]).delete respond_with do |format| - format.json{ render :nothing => true, :status => 204 } + format.json { head :no_content } end end diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 2e94ffd100a906b37484698de0797b405f9d538a..214f484bb5b3bc96001f56148ffec2fdb2d26bbf 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -8,7 +8,7 @@ class CommentsController < ApplicationController respond_to :html, :mobile, :json rescue_from ActiveRecord::RecordNotFound do - render nothing: true, status: 404 + head :not_found end def create @@ -57,7 +57,7 @@ class CommentsController < ApplicationController def respond_create_success(comment) respond_to do |format| format.json { render json: CommentPresenter.new(comment), status: 201 } - format.html { render nothing: true, status: 201 } + format.html { head :created } format.mobile { render partial: "comment", locals: {comment: comment} } end end @@ -65,16 +65,16 @@ class CommentsController < ApplicationController def respond_destroy_success respond_to do |format| format.mobile { redirect_back fallback_location: stream_path } - format.js { render nothing: true, status: 204 } - format.json { render nothing: true, status: 204 } + format.js { head :no_content } + format.json { head :no_content } end end def respond_destroy_error respond_to do |format| format.mobile { redirect_back fallback_location: stream_path } - format.js { render nothing: true, status: 403 } - format.json { render nothing: true, status: 403 } + format.js { head :forbidden } + format.json { head :forbidden } end end end diff --git a/app/controllers/conversations_controller.rb b/app/controllers/conversations_controller.rb index c69b6d7d811861811149b377e9fc5b10601abbf3..16451283997e1ffef9e69f43e7127bc2fb658a69 100644 --- a/app/controllers/conversations_controller.rb +++ b/app/controllers/conversations_controller.rb @@ -82,7 +82,7 @@ class ConversationsController < ApplicationController @conversation.set_read(current_user) render partial: "conversations/show", locals: {conversation: @conversation} else - render nothing: true, status: 404 + head :not_found end end diff --git a/app/controllers/likes_controller.rb b/app/controllers/likes_controller.rb index 20fe1dd690dc2a1efe2113409d7141c812002ab1..de508f35146f72231043224a9539bddf314002ea 100644 --- a/app/controllers/likes_controller.rb +++ b/app/controllers/likes_controller.rb @@ -16,7 +16,7 @@ class LikesController < ApplicationController render text: I18n.t("likes.create.error"), status: 422 else respond_to do |format| - format.html { render nothing: true, status: 201 } + format.html { head :created } format.mobile { redirect_to post_path(like.post_id) } format.json { render json: like.as_api_response(:backbone), status: 201 } end @@ -24,7 +24,7 @@ class LikesController < ApplicationController def destroy if like_service.destroy(params[:id]) - render nothing: true, status: 204 + head :no_content else render text: I18n.t("likes.destroy.error"), status: 404 end diff --git a/app/controllers/participations_controller.rb b/app/controllers/participations_controller.rb index 95e8a2c0382481dc928ac44a6a546ca6d3e55f4a..1cb9b7b40f2798bc0ae44fb01c41fdfc94585a79 100644 --- a/app/controllers/participations_controller.rb +++ b/app/controllers/participations_controller.rb @@ -5,9 +5,9 @@ class ParticipationsController < ApplicationController post = current_user.find_visible_shareable_by_id(Post, params[:post_id]) if post current_user.participate! post - render nothing: true, status: :created + head :created else - render nothing: true, status: :forbidden + head :forbidden end end @@ -15,9 +15,9 @@ class ParticipationsController < ApplicationController participation = current_user.participations.find_by target_id: params[:post_id] if participation participation.destroy - render nothing: true, status: :ok + head :ok else - render nothing: true, status: :unprocessable_entity + head :unprocessable_entity end end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 7c3d5a2e7b4e0ec45af5b710c8b6a5bf0603d27b..f42a4d90850d06bd3c40479a3d0557c5427b5537 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -20,7 +20,7 @@ class PeopleController < ApplicationController rescue_from Diaspora::AccountClosed do respond_to do |format| format.any { redirect_back fallback_location: root_path, notice: t("people.show.closed_account") } - format.json { render :nothing => true, :status => 410 } # 410 GONE + format.json { head :gone } end end @@ -115,15 +115,15 @@ class PeopleController < ApplicationController def retrieve_remote if params[:diaspora_handle] Workers::FetchWebfinger.perform_async(params[:diaspora_handle]) - render :nothing => true + head :ok else - render :nothing => true, :status => 422 + head :unprocessable_entity end end def contacts respond_to do |format| - format.json { render nothing: true, status: 406 } + format.json { head :not_acceptable } format.any do @person = Person.find_by_guid(params[:person_id]) diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index d4da48654447cb2cd2a35ac42ff48f509b08d662..a95fdb42001d599fc3df14b29c5ed6ea8bcedf41 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -66,10 +66,10 @@ class PhotosController < ApplicationController :status => 201} end else - render :nothing => true, :status => 422 + head :unprocessable_entity end else - render :nothing => true, :status => 422 + head :unprocessable_entity end end @@ -80,7 +80,7 @@ class PhotosController < ApplicationController current_user.retract(photo) respond_to do |format| - format.json{ render :nothing => true, :status => 204 } + format.json { head :no_content } format.html do flash[:notice] = I18n.t 'photos.destroy.notice' if StatusMessage.find_by_guid(photo.status_message_guid) diff --git a/app/controllers/poll_participations_controller.rb b/app/controllers/poll_participations_controller.rb index ae8eea8355269320ec5de289e44de51f1c638201..a8b874fca1662ba3c562201a11aef17fa7ba3bb6 100644 --- a/app/controllers/poll_participations_controller.rb +++ b/app/controllers/poll_participations_controller.rb @@ -11,7 +11,7 @@ class PollParticipationsController < ApplicationController rescue ActiveRecord::RecordInvalid respond_to do |format| format.mobile { redirect_to stream_path } - format.json { render :nothing => true, :status => 403 } + format.json { head :forbidden } end end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 6435ed3ad5708e823fc3d5a8d28e43b7b86ce785..1629fb7656a318cc6ab8a298c5662498793443ef 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -36,7 +36,7 @@ class PostsController < ApplicationController oembed = params.slice(:format, :maxheight, :minheight) render json: OEmbedPresenter.new(post, oembed) rescue - render nothing: true, status: 404 + head :not_found end def interactions @@ -45,7 +45,7 @@ class PostsController < ApplicationController post = post_service.find!(params[:id]) render json: PostInteractionPresenter.new(post, current_user) } - format.any { render nothing: true, status: 406 } + format.any { head :not_acceptable } end end @@ -55,19 +55,19 @@ class PostsController < ApplicationController if params[:id].present? && params[:q].present? render json: post_service.mentionable_in_comment(params[:id], params[:q]) else - render nothing: true, status: 204 + head :no_content end } - format.any { render nothing: true, status: 406 } + format.any { head :not_acceptable } end rescue ActiveRecord::RecordNotFound - render nothing: true, status: 404 + head :not_found end def destroy post_service.destroy(params[:id]) respond_to do |format| - format.json { render nothing: true, status: 204 } + format.json { head :no_content } format.any { redirect_to stream_path } end end diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 2ff157c49a130c7c4167ad5b8ce630e94c6aecdc..9daa4640d1ece23179267b42c2f0f92e2016980b 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -48,7 +48,7 @@ class ProfilesController < ApplicationController end respond_to do |format| - format.js { render :nothing => true, :status => 200 } + format.js { head :ok } format.any { if current_user.getting_started? redirect_to getting_started_path diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb index 8e0826c1f4ea271a45ce061e2a5d9559a4f37835..f51d2d043050e1aabcfb6b343ff0bf77a0a85bee 100644 --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -31,7 +31,7 @@ class ReportController < ApplicationController if report.save render json: true, status: 200 else - render nothing: true, status: 409 + head :conflict end end diff --git a/app/controllers/tag_followings_controller.rb b/app/controllers/tag_followings_controller.rb index 72ca6fd2405c04eea775233390e6494eafe38008..a82d16dd94b03e128fd67b5ff3952a66df49f54f 100644 --- a/app/controllers/tag_followings_controller.rb +++ b/app/controllers/tag_followings_controller.rb @@ -15,7 +15,7 @@ class TagFollowingsController < ApplicationController name_normalized = ActsAsTaggableOn::Tag.normalize(params['name']) if name_normalized.nil? || name_normalized.empty? - render :nothing => true, :status => 403 + head :forbidden else @tag = ActsAsTaggableOn::Tag.find_or_create_by(name: name_normalized) @tag_following = current_user.tag_followings.new(:tag_id => @tag.id) @@ -23,7 +23,7 @@ class TagFollowingsController < ApplicationController if @tag_following.save render :json => @tag.to_json, :status => 201 else - render :nothing => true, :status => 403 + head :forbidden end end end @@ -35,11 +35,11 @@ class TagFollowingsController < ApplicationController if tag_following && tag_following.destroy respond_to do |format| - format.any(:js, :json) { render :nothing => true, :status => 204 } + format.any(:js, :json) { head :no_content } end else respond_to do |format| - format.any(:js, :json) {render :nothing => true, :status => 403} + format.any(:js, :json) { head :forbidden } end end end diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 30ddfec0005f25098d20bb736e50e61a0cbb78b5..d201fd905f015b2f61c1f13bc7769d401057da14 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -24,8 +24,8 @@ class TagsController < ApplicationController end else respond_to do |format| - format.json{ render :nothing => true, :status => 422 } - format.html{ redirect_to tag_path('partytimeexcellent') } + format.json { head :unprocessable_entity } + format.html { redirect_to tag_path("partytimeexcellent") } end end end