To make this work, it was required to add the "only_path: true" parameter to route_for, i.e.
direct :rails_public_blob do |blob|
if Rails.env.production?
File.join("cdn.example.com", blob.key)
else
route_for(:rails_blob, blob, only_path: true)
end
end
Without "only_path: true", I was getting this message:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
After this was fixed, howerver, I noticed that the rails_public_blob helper started returning a path to the "master" image and not to the variant, i.e.
force the creation of the variant:
current_user.avatar.variant(variant_options).processed
Thank you for your kind response.
To make this work, it was required to add the "only_path: true" parameter to route_for, i.e.
direct :rails_public_blob do |blob|
if Rails.env.production?
File.join("cdn.example.com", blob.key)
else
route_for(:rails_blob, blob, only_path: true)
end
end
Without "only_path: true", I was getting this message:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
After this was fixed, howerver, I noticed that the rails_public_blob helper started returning a path to the "master" image and not to the variant, i.e.
force the creation of the variant:
current_user.avatar.variant(variant_options).processed
blob = current_user.avatar.variant(variant_options).blob
image_path = Rails.application.routes.url_helpers.rails_public_blob_url(blob)
image_path points to the master image, not to the variant. This wasn't happening before. Any ideas? :)
Thanks for any insight!
-Eduardo
Hi Eduardo
I just updated the post with the solution for variants. Please have a look. It appears variants have their own URL helper
rails_representation_url
.Thank you, Florin! It works wonderful now. I still needed to add "only_path: true" to "route_for", i.e.:
route_for(route, blob, only_path: true)
Thanks for the great post and the generous assistance. 😊