shajin
shajin

Reputation: 3264

What does "save(false)" do?

In the following code, what does save(false) do?

def create_reset_code!  
    @reset = true  
    self.attributes = {:reset_code => Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )}  
    save(false)  
  end  

If it's for updating the credentials, then why do they include false?

Upvotes: 10

Views: 5774

Answers (2)

Mörre
Mörre

Reputation: 5723

save(false) bypasses validations for the model object being saved.

Upvotes: 17

mecampbellsoup
mecampbellsoup

Reputation: 1501

Old Rails version:

save(false)

New Rails version per the docs:

save(validate: false)

Upvotes: 8

Related Questions