We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Given a countries table with two rows:
countries
And a model
class Country < ActiveRecord::Base lookup_by :name, cache: true end
Prior to v0.11, we'd see:
Country.first.name # => "China"
because this actually executes a db query (which implicitly orders by insertion).
Afterwards, since Country.all hits the cache instead, we see:
Country.all
Country.first.name # => "America"
because the cache orders based on the cache key (alphabetically).
This can be overridden by using the (undocumented) :order option:
:order
class Country < ActiveRecord::Base lookup_by :name, cache: true, order: :country_id end Country.first.name # => "China"
but this is tedious and arguably should be the default behavior.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Given a
countries
table with two rows:And a model
Prior to v0.11, we'd see:
because this actually executes a db query (which implicitly orders by insertion).
Afterwards, since
Country.all
hits the cache instead, we see:because the cache orders based on the cache key (alphabetically).
This can be overridden by using the (undocumented)
:order
option:but this is tedious and arguably should be the default behavior.
The text was updated successfully, but these errors were encountered: