Created
January 18, 2016 09:12
-
-
Save josepjaume/c066091d5d4723ba19fb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
if @account.organization? | |
params.require(:account).permit(:phone_number, :email_on_comment, :email_on_comment_reply, :newsletter, organization_attributes: [:name, :responsible_name]) | |
else | |
params.require(:account).permit(:username, :public_activity, :email_on_comment, :email_on_comment_reply, :newsletter) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment