最后,我发现他们通过声明元素声明了很多全局变量(类实例变量)。
Finally, it dawned on me that they had declared many variables with global scope (class instance variables) via declaration elements.
如果将一个类实例变量赋给另一个类,它们不仅具有相同的数据类型,还在内存中指向相同的类实例。
If you assign one class instance variable to another, not only do they have the same data type, they point to the same class instance in memory.
不需要通过 read_inheritable_attribute 宏来使用属性,因为这是 ActiveRecord 定义的类实例变量。
There's no need to go through the read_inheritable_attribute macro to use attributes because these are class instance variables defined by ActiveRecord.
应用推荐