3 ms·
New Rails dev here: I believe the entire ActiveRecord model is constant monkey patching.
by t-writescode 7y ago
New Rails dev here: I believe the entire ActiveRecord model is constant monkey patching.
- FooBarWidget 7y agoLong time Rails dev here. I believe not. The Rails core devs have long known that monkey patching is not thread safe, and blows Ruby method caches, so they already reserve monkey patching for initialization time.
- toasterlovin 7y agoDo you have something specific in mind? From my understanding of ActiveRecord, most of the method generation should happen the first time the class is defined.
- thomasfedb 7y agoI feel that the definition of "monkey patching" doesn't (or shouldn't) cover what Rails does in AR. Monkey patch suggests a change of behaviour over what was initially intended, however dynamic method generation in AR is very-much part of the intended API. That said, there are plenty of Rails apps that do monkey patch Rails internals, for better or worse.