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
I would expect that calling #reload on an instance of an ActiveRecord model would flush the cache.
#reload
If I have a table named foos with one string column name:
foos
name
class Foo < ActiveRecord::Base extend Memoist memoize def change_name! name = 'bar' save name end end
describe Foo do describe '#change_name!' do subject { Foo.create(name: '') } expect { subject.change_name! }.to change { subject.reload.name }from('').to('bar') end end
The above test fails unless #flush_cache is called on subject in the change block. Is this the intended behavior?
#flush_cache
subject
The text was updated successfully, but these errors were encountered:
@stevenspiel I agree this is surprising, and have at various times had solutions for this in my local projects.
As I remember there's no official callback for a reload so to make an instance variable be reset for a reload is a bit of a hack.
reload
I wouldn't mind adding an opportunity optional module that could be prepended, or just add something to the docs.
prepended
Something like
module Memoist::ActiveRecordReloadable def reload flush_cache super end end MyModel.prepend(Memoist::ActiveRecordReloadable)
Sorry, something went wrong.
No branches or pull requests
I would expect that calling
#reload
on an instance of an ActiveRecord model would flush the cache.If I have a table named
foos
with one string columnname
:The above test fails unless
#flush_cache
is called onsubject
in the change block. Is this the intended behavior?The text was updated successfully, but these errors were encountered: