What is use of "define_write_method" in ruby , I tried to understasnd it, but did not get it? -


def define_write_method(attr_name)   evaluate_attribute_method attr_name, "def #{attr_name}=(new_value);write_attribute('#{attr_name}', new_value);end", "#{attr_name}=" end 

this available in docs theoritack description not available, in advance.

it looks 1 of methods added activerecord object. ar reads schema information database , create writer methods columns.

this way, can point ar-class table (or let conventions this) , have ability "write" data object. when save it, attributes persisted database.


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

clojure - 'get' replacement that throws exception on not found? -