Difference between was, before_last_save, changed and changed?

 


was: in the update action before update record if you want previous price not updated price then you should use @product.price_was

before_last_save:  in the update action after update record if you want previous price not updated price then you should use @product.price_before_last_save

changed?:  if you want to check your object is update or not? OR any value of object is updated or not then user this function.(Eg. @product.changed?)

changed: if you want to check  what fields is updated  (Eg. @product.changed)

Comments

Popular posts from this blog

Standard of Code Sequence of model

Setup Rspec