-
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
Incorrect url generated for versions of different format #378
Comments
Note that the uploader expects the "reflected" version to have an extension of ".jpg" instead of the correct ".png" extension? |
If you're able to figure it out, a failing test case would be great to see. |
So on further investigating, it looks like this isn't so much a defect as it is lack of clarity. What's happening is when you store an image, the "filename" method is called (and in the case of my class above) given a chance to mutate the filename as it will be written to the store and subsequently stored in the database. So it works as expected when creating new images. However, on retrieving an image, the "identifier" stored in the database is used to construct even the version's path. The "filename" method is not called during retrieval to allow the same mutation to occur, thus the problem. Fortunately, it looks like the whole problem can be avoided by overwriting "full_filename" instead of "filename" inside my versions. This method is invoked on both store! and retrieve_from_store! and thus allows the identifier stored in the database to be mutated properly. Here is a revised copy of my Uploader that works correctly:
While testing, I did discover that for some reason, versions are handled differently when the uploader is mounted versus not mounted, but I will open a new issue to address that. |
Awesome - glad you figured this out. If you think an addition to the wiki or readme is called for, please do pitch in. Thanks! |
I have an uploader that converts a version to a different format and applies some additional transformations. Initially, everything works, but after loading the model instance from the database, the uploader isn't generating the correct path or url for the version.
Here is my uploader class:
And here's what happens when I reload the instance (using rails console):
I haven't quite figured out what's going wrong, but clearly the custom filename method on the "reflected" version is not being accounted for. If I check the versions filename, I get something like this:
Oops! What's nil here? Calls to super?
The text was updated successfully, but these errors were encountered: