Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Devise - skip user password validation in a rake task


  • Please log in to reply
2 replies to this topic

#1 Javix

Javix

    Passenger

  • Members
  • 3 posts

Posted 09 October 2013 - 11:35 AM

Is there any way to skip Devise password validation when creating multiple users in a rake task ?

Thank you.

 

 



#2 stevieing

stevieing

    Dispatcher

  • Members
  • 40 posts

Posted 09 October 2013 - 11:54 AM

user.save(false)

 

Should skip validations

 

Steve.



#3 Ohm

Ohm

    Guard

  • Members
  • 179 posts
  • LocationCopenhagen

Posted 09 October 2013 - 06:24 PM

As per the docs (http://api.rubyonrai...l#method-i-save) the correct way to save without validations is

user.save(validate: false)

Note that it can still fail (and return false) due to before_action, before_filters and the like.


Blog: http://ohm.sh | Twitter: madsohm





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users