-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
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
lately resolve active versions when retrieving #2669
base: master
Are you sure you want to change the base?
lately resolve active versions when retrieving #2669
Conversation
def retrieve_versions_from_cache!(cache_name) | ||
active_versions.each { |name, v| v.retrieve_from_cache!(cache_name) } | ||
versions.each { |name, v| v.retrieve_from_cache!(cache_name) } | ||
end | ||
|
||
def retrieve_versions_from_store!(identifier) | ||
active_versions.each { |name, v| v.retrieve_from_store!(identifier) } | ||
versions.each { |name, v| v.retrieve_from_store!(identifier) } | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to evaluate the condition here, like before the changes in #1351 .
We can keep all versions retrieved internally, evaluate the condition and return them only when users accesses.
@@ -133,7 +133,7 @@ def version(name, options = {}, &block) | |||
|
|||
class_eval <<-RUBY, __FILE__, __LINE__ + 1 | |||
def #{name} | |||
versions[:#{name}] | |||
version_exists?(:#{name}) ? versions[:#{name}] : versions[:#{name}].class.new(model, mounted_as) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lately resolving the condition here. Which would make it more consistent with the current state (active or not) of the version (which fixes #2148 too).
I think it is better to return nil for non-active versions, but returning a blank uploader for backwards compatibility.
I added some comments to make the change clearer. Hope this makes sense 😄 |
Looking at #2132 |
I believe this fixes #2461 #2148
#2132Minimum reproducible example and details are in
#2461 (comment)