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

validate_presence_of fails on Rails 6 #1167

Closed
sosodev opened this issue Jan 20, 2019 · 7 comments · Fixed by #1193
Labels
Milestone

Comments

@sosodev
Copy link

@sosodev sosodev commented Jan 20, 2019

validate_presence_of relies on the constant ActiveModel::SecurePassword::InstanceMethodsOnActivation

which has been removed in Rails 6 rails/rails@08dde0f#diff-a6f9af64a6d420eb1103e16c0a0a8f04L66

@nicholasshirley

This comment has been minimized.

Copy link
Contributor

@nicholasshirley nicholasshirley commented Jan 20, 2019

Found the same.

Looks like the third check could also return false when it should return true because the attribute can be assigned by the user now instead of always being password.

def secure_password_being_validated?
defined?(::ActiveModel::SecurePassword) &&
@subject.class.ancestors.include?(::ActiveModel::SecurePassword::InstanceMethodsOnActivation) &&
@attribute == :password
end

@mcmire mcmire added the 🛤 Rails 6 label Jan 21, 2019
@joshRpowell

This comment has been minimized.

Copy link

@joshRpowell joshRpowell commented Jan 25, 2019

related #1117

@yagudaev

This comment has been minimized.

Copy link

@yagudaev yagudaev commented Mar 9, 2019

It would be really nice to have this fixed with new version of rails around the corner.

As a temporary workaround (as I did not need the password matchers) I used:

# spec/rails_helper.rb - add to bottom
class ActiveModel::SecurePassword::InstanceMethodsOnActivation; end;
@mcmire

This comment has been minimized.

Copy link
Collaborator

@mcmire mcmire commented Mar 9, 2019

@yagudaev We plan on including support for Rails 6 in the next immediate version, so this is included in the list of upcoming changes.

@nscmnto

This comment has been minimized.

Copy link

@nscmnto nscmnto commented Mar 10, 2019

@yagudaev thanks for the workaround!

@mcmire

This comment has been minimized.

Copy link
Collaborator

@mcmire mcmire commented Apr 23, 2019

This is fixed now! ^

@connorshea

This comment has been minimized.

Copy link
Contributor

@connorshea connorshea commented Apr 24, 2019

@mcmire can we get a new release now that Rails 6.0.0.rc1 is out? :) I just ran my test suite with the latest master on Rails 6 and it worked great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.