开发者

What does "save(false)" do?

开发者 https://www.devze.com 2023-02-13 19:25 出处:网络
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 )}

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, the开发者_JAVA百科n why do they include false?


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


Old Rails version:

save(false)

New Rails version per the docs:

save(validate: false)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号