Skip to content

Instantly share code, notes, and snippets.

@tamouse
Last active December 23, 2015 02:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tamouse/6567890 to your computer and use it in GitHub Desktop.
Save tamouse/6567890 to your computer and use it in GitHub Desktop.
def object_changed?(instance, params)
instance.attributes != instance.attributes.merge(params)
end
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