Last active
December 23, 2015 02:38
-
-
Save tamouse/6567890 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
def object_changed?(instance, params) | |
instance.attributes != instance.attributes.merge(params) | |
end |
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
def update | |
unless object_changed?(@account, accounts_params) | |
redirect_to accounts_path, notice: "There were no changes to be made." | |
return | |
end | |
if @account.update(accounts_params) | |
redirect_to accounts_path, notice: "Account updated." | |
else | |
flash.now[:error] = "Account could not be updated." | |
render action: :edit | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment