Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates: use update instead of update_attributes #1314

Merged
merged 1 commit into from
Aug 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/devise_token_auth/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def update
def resource_update_method
allow_password_change = recoverable_enabled? && @resource.allow_password_change == true
if DeviseTokenAuth.check_current_password_before_update == false || allow_password_change
'update_attributes'
'update'
else
'update_with_password'
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ def resource_update_method
elsif account_update_params.key?(:current_password)
'update_with_password'
else
'update_attributes'
'update'
end
end

Expand Down
4 changes: 2 additions & 2 deletions test/controllers/demo_user_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ class DemoUserControllerTest < ActionDispatch::IntegrationTest
assert @resource.tokens.count > 1

# password changed from new device
@resource.update_attributes(password: 'newsecret123',
password_confirmation: 'newsecret123')
@resource.update(password: 'newsecret123',
password_confirmation: 'newsecret123')

get '/demo/members_only',
params: {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class RegistrationsController < DeviseTokenAuth::RegistrationsController

def update
if @resource
if @resource.update_attributes(account_update_params)
if @resource.update(account_update_params)
render json: {
status: 'success',
data: @resource.as_json,
Expand Down