3 ms·
An article dedicated to why Rail's Active Record library isn't actually using the Active Record pattern would be interesting!
by ptr 7y ago
An article dedicated to why Rail's Active Record library isn't actually using the Active Record pattern would be interesting!
- calpaterson 7y agoYes I am curious about that. Someone else said that the Rails authors used to like and defend this pattern and that presumably they changed their mind. Maybe because they ran into problems? I'm not at all close to the Ruby community but would love to know. https://lobste.rs/s/valayp/troublesome_active_record_pattern#c_z6woqa https://lobste.rs/s/valayp/troublesome_active_record_pattern...
- dhagz 7y agoThat's my general impression. As Rails grew in popularity and was used for more and more complex things (with more and more complex database tables), they started to add in the raw query building parts of ActiveRecord. Though I think it was more that they wanted raw query functionality in the library and it made most sense to enhance the tool that already dealt with the database rather than add another alongside it.
- zrail 7y agoRails' ActiveRecord is both a query builder and also the canonical Active Record pattern. For example, one can say book = Books.joins(:authors).where(author_name: 'James S. A. Corey').first book.title = "Tiamat's Wrath" book.save! It's not that they stopped supporting the Active Record pattern, it's that they rebuilt the whole thing a few years ago with a real relational query builder under the hood.
- inopinatus 7y agoIt’s more like the repository pattern under the bonnet.