activerecord - How to get current value of attribute before saving new one in AR? -


i have model such attributes:

  1. some_number
  2. some_string

i want put value in some_string depending on current value of some_number , new value of some_number on updating.

example:

current some_number 4

new (updated) value of some_number 5

i want put 4+5 string some_string before some_number overwritten.

how can worked?

if need modify attribute depending on other attribute value on update event i'd that:

class thing < activerecord::base     before_update :modify_some_string     protected     def modify_some_string             # actions self.some_string , self.some_number             # , self.some_string_was , self.some_number_was     end end 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

xcode - Swift Playground - Files are not readable -

jboss7.x - JBoss AS 7.3 vs 7.4 and differences -