Simplify render in controllers (#2144)

pull/2150/head
Matt Jankowski 2017-04-19 09:37:42 -04:00 committed by Eugen
parent bfbc2ca0d8
commit a8e1afc30a
9 changed files with 27 additions and 27 deletions

View File

@ -17,7 +17,7 @@ module Admin
DomainBlockWorker.perform_async(@domain_block.id) DomainBlockWorker.perform_async(@domain_block.id)
redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.created_msg') redirect_to admin_domain_blocks_path, notice: I18n.t('admin.domain_blocks.created_msg')
else else
render action: :new render :new
end end
end end

View File

@ -13,13 +13,13 @@ class Api::V1::AccountsController < ApiController
def verify_credentials def verify_credentials
@account = current_user.account @account = current_user.account
render action: :show render :show
end end
def update_credentials def update_credentials
current_account.update!(account_params) current_account.update!(account_params)
@account = current_account @account = current_account
render action: :show render :show
end end
def following def following
@ -32,7 +32,7 @@ class Api::V1::AccountsController < ApiController
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
render action: :index render :index
end end
def followers def followers
@ -45,7 +45,7 @@ class Api::V1::AccountsController < ApiController
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
render action: :index render :index
end end
def statuses def statuses
@ -65,7 +65,7 @@ class Api::V1::AccountsController < ApiController
def follow def follow
FollowService.new.call(current_user.account, @account.acct) FollowService.new.call(current_user.account, @account.acct)
set_relationship set_relationship
render action: :relationship render :relationship
end end
def block def block
@ -77,31 +77,31 @@ class Api::V1::AccountsController < ApiController
@requested = { @account.id => false } @requested = { @account.id => false }
@muting = { @account.id => current_user.account.muting?(@account.id) } @muting = { @account.id => current_user.account.muting?(@account.id) }
render action: :relationship render :relationship
end end
def mute def mute
MuteService.new.call(current_user.account, @account) MuteService.new.call(current_user.account, @account)
set_relationship set_relationship
render action: :relationship render :relationship
end end
def unfollow def unfollow
UnfollowService.new.call(current_user.account, @account) UnfollowService.new.call(current_user.account, @account)
set_relationship set_relationship
render action: :relationship render :relationship
end end
def unblock def unblock
UnblockService.new.call(current_user.account, @account) UnblockService.new.call(current_user.account, @account)
set_relationship set_relationship
render action: :relationship render :relationship
end end
def unmute def unmute
UnmuteService.new.call(current_user.account, @account) UnmuteService.new.call(current_user.account, @account)
set_relationship set_relationship
render action: :relationship render :relationship
end end
def relationships def relationships
@ -118,7 +118,7 @@ class Api::V1::AccountsController < ApiController
def search def search
@accounts = AccountSearchService.new.call(params[:q], limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:resolve] == 'true', current_account) @accounts = AccountSearchService.new.call(params[:q], limit_param(DEFAULT_ACCOUNTS_LIMIT), params[:resolve] == 'true', current_account)
render action: :index render :index
end end
private private

View File

@ -10,7 +10,7 @@ class Api::V1::FollowsController < ApiController
raise ActiveRecord::RecordNotFound if follow_params[:uri].blank? raise ActiveRecord::RecordNotFound if follow_params[:uri].blank?
@account = FollowService.new.call(current_user.account, target_uri).try(:target_account) @account = FollowService.new.call(current_user.account, target_uri).try(:target_account)
render action: :show render :show
end end
private private

View File

@ -40,7 +40,7 @@ class Api::V1::StatusesController < ApiController
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
render action: :accounts render :accounts
end end
def favourited_by def favourited_by
@ -53,7 +53,7 @@ class Api::V1::StatusesController < ApiController
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
render action: :accounts render :accounts
end end
def create def create
@ -62,7 +62,7 @@ class Api::V1::StatusesController < ApiController
spoiler_text: status_params[:spoiler_text], spoiler_text: status_params[:spoiler_text],
visibility: status_params[:visibility], visibility: status_params[:visibility],
application: doorkeeper_token.application) application: doorkeeper_token.application)
render action: :show render :show
end end
def destroy def destroy
@ -73,7 +73,7 @@ class Api::V1::StatusesController < ApiController
def reblog def reblog
@status = ReblogService.new.call(current_user.account, Status.find(params[:id])) @status = ReblogService.new.call(current_user.account, Status.find(params[:id]))
render action: :show render :show
end end
def unreblog def unreblog
@ -83,12 +83,12 @@ class Api::V1::StatusesController < ApiController
RemovalWorker.perform_async(reblog.id) RemovalWorker.perform_async(reblog.id)
render action: :show render :show
end end
def favourite def favourite
@status = FavouriteService.new.call(current_user.account, Status.find(params[:id])).status.reload @status = FavouriteService.new.call(current_user.account, Status.find(params[:id])).status.reload
render action: :show render :show
end end
def unfavourite def unfavourite
@ -97,7 +97,7 @@ class Api::V1::StatusesController < ApiController
UnfavouriteWorker.perform_async(current_user.account_id, @status.id) UnfavouriteWorker.perform_async(current_user.account_id, @status.id)
render action: :show render :show
end end
private private

View File

@ -17,7 +17,7 @@ class Api::V1::TimelinesController < ApiController
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
render action: :index render :index
end end
def public def public
@ -31,7 +31,7 @@ class Api::V1::TimelinesController < ApiController
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
render action: :index render :index
end end
def tag def tag
@ -46,7 +46,7 @@ class Api::V1::TimelinesController < ApiController
set_pagination_headers(next_path, prev_path) set_pagination_headers(next_path, prev_path)
render action: :index render :index
end end
private private

View File

@ -18,7 +18,7 @@ class Settings::ImportsController < ApplicationController
ImportWorker.perform_async(@import.id) ImportWorker.perform_async(@import.id)
redirect_to settings_import_path, notice: I18n.t('imports.success') redirect_to settings_import_path, notice: I18n.t('imports.success')
else else
render action: :show render :show
end end
end end

View File

@ -29,7 +29,7 @@ class Settings::PreferencesController < ApplicationController
if current_user.update(user_params.except(:notification_emails, :interactions, :setting_default_privacy, :setting_boost_modal, :setting_auto_play_gif)) if current_user.update(user_params.except(:notification_emails, :interactions, :setting_default_privacy, :setting_boost_modal, :setting_auto_play_gif))
redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg') redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg')
else else
render action: :show render :show
end end
end end

View File

@ -17,7 +17,7 @@ class Settings::ProfilesController < ApplicationController
if @account.update(account_params) if @account.update(account_params)
redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg') redirect_to settings_profile_path, notice: I18n.t('generic.changes_saved_msg')
else else
render action: :show render :show
end end
end end

View File

@ -26,7 +26,7 @@ class Settings::TwoFactorAuthsController < ApplicationController
@confirmation = Form::TwoFactorConfirmation.new @confirmation = Form::TwoFactorConfirmation.new
set_qr_code set_qr_code
flash.now[:alert] = I18n.t('two_factor_auth.wrong_code') flash.now[:alert] = I18n.t('two_factor_auth.wrong_code')
render action: :new render :new
end end
end end