3 ms·
It's possible to do that in AdequateRecord, but I've purposely left the mechanism undocumented because the API is not stable. You can do something like this:
by tenderlove 13y ago
It's possible to do that in AdequateRecord, but I've purposely left the mechanism undocumented because the API is not stable. You can do something like this:
statement = undocumented_method_call { |params|
Article.where(xxx: params[:xxx])
}
statement.execute xxx: "some value"
https://github.com/rails/rails/blob/e5e440f477a0b5e06b008ee77e3c635049405957/activerecord/test/cases/statement_cache_test.rb#L18-L20 https://github.com/rails/rails/blob/e5e440f477a0b5e06b008ee7...
The trick is that the cache only supports caching ActiveRecord::Relation objects, and not everyone knows which calls will return a Relation object. For now, I want to hide this API and make it as "automatic" as possible so that people don't have to change app code, but still get performance boosts.