Is there a way to get the current variable? let's say that I have the "title" attribute in the method and I want to register with the old value of the variable?
How can i do this?
ActiveRecord provides a whole set of methods that work with Dirty attributes .
In your case, you can call title_wasto get the most recent saved version of this variable
title_was
, changed_attributes, , ( , - ).
, old_name:
a = YourModel.where(:title => "old_name") a.title = "new_title" a.changed_attributes
: { "" = > "old_name" }
:
a.save a.changed_attributes
: {}
Source: https://habr.com/ru/post/1764382/More articles:rails popup page - ruby-on-railsHow to include image in window with pygtk? - pythonASP.NET MVC Engine Performance - performanceD_FORTIFY_SOURCE и gcc - cNamespace in the definition and implementation - c ++Error trying to compile Erlang R13B04 for ARM - armUnicodeEncodeError when choosing urls - pythonhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1764385/erlang-writing-integer-values-to-a-file&usg=ALkJrhhUbhPlPjuv4qt0YWGqPlwbn4cz0wЯвляется ли хранение SQL-запросов в базе данных плохим? - sqlIn practice, what is the best choice: hash table, base tree, red ebony or ...? - algorithmAll Articles