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

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -