Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get current variable Rails, in before_save

Is there a way to get the current variable? lets say that i have a "title" attribute in a method and i want to check in with the old value of the variable ?

how could i accomplish this ?

like image 579
heldopslippers Avatar asked Aug 03 '26 06:08

heldopslippers


1 Answers

ActiveRecord provides a whole set of methods which work on "Dirty" attributes.

In your case, you can call title_was to get the most recently saved version of that variable

like image 189
Gareth Avatar answered Aug 06 '26 00:08

Gareth