We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
36 lines
1.1 KiB
Ruby
36 lines
1.1 KiB
Ruby
class AccountController < ApplicationController
|
|
before_action :authenticate_user!
|
|
before_action :set_account
|
|
load_and_authorize_resource class: "User"
|
|
|
|
def show
|
|
end
|
|
|
|
def update
|
|
if @account.update(account_params)
|
|
redirect_to account_path, notice: t("flash.actions.save_changes.notice")
|
|
else
|
|
@account.errors.messages.delete(:organization)
|
|
render :show
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def set_account
|
|
@account = current_user
|
|
end
|
|
|
|
def account_params
|
|
attributes = if @account.organization?
|
|
[:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter,
|
|
organization_attributes: [:name, :responsible_name]]
|
|
else
|
|
[:username, :public_activity, :public_interests, :email_on_comment,
|
|
:email_on_comment_reply, :email_on_direct_message, :email_digest, :newsletter,
|
|
:official_position_badge, :recommended_debates, :recommended_proposals]
|
|
end
|
|
params.require(:account).permit(*attributes)
|
|
end
|
|
end
|