Giter Site home page Giter Site logo

Comments (8)

jankeesvw avatar jankeesvw commented on August 10, 2024 9

I found a workaround. When I use the url_for helper it gets the right URL. This issue is probably not caused by Turbo so I'm going to close it.

This works:

<%= image_tag url_for(vehicle.image_with_fallback.variant(resize_to_fill: [424, 220])) %>

This yields:

http://stekker.test/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBKQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--cb6db5fb76e9c8fc3e226d7d8eff69917a35d5ee/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lKYW5CbFp3WTZCa1ZVT2hOeVpYTnBlbVZmZEc5ZlptbHNiRnNIYVFLb0FXa0IzQT09IiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--b0a6e29b924216f0f5dcb59d63681f10c84e9994/ev-database.jpeg

This doesn't work

<%= image_tag vehicle.image_with_fallback.variant(resize_to_fill: [424, 220]) %>

This yields:

http://example.org/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBKQT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--cb6db5fb76e9c8fc3e226d7d8eff69917a35d5ee/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaDdCem9MWm05eWJXRjBTU0lKYW5CbFp3WTZCa1ZVT2hOeVpYTnBlbVZmZEc5ZlptbHNiRnNIYVFLb0FXa0IzQT09IiwiZXhwIjpudWxsLCJwdXIiOiJ2YXJpYXRpb24ifX0=--b0a6e29b924216f0f5dcb59d63681f10c84e9994/ev-database.jpeg

from turbo-rails.

unRARed avatar unRARed commented on August 10, 2024 1

@jankeesvw I can confirm the workaround for direct attachments, but the problem is compounded with the use of ActionText. You don't have control over building the URL in that scenario... or at least not in any obvious way that I could find. Did you determine the culprit if not Turbo?

from turbo-rails.

jankeesvw avatar jankeesvw commented on August 10, 2024 1

No, sorry. I'm just using url_for right now.

from turbo-rails.

brendon avatar brendon commented on August 10, 2024

I suspect this is caused when an asset_host is defined. In that case an image_tag would link to an absolute url with the asset host by default. When an attachment is passed instead it seems to want to still build an absolute url and looks for that at config.action_controller.default_url_options or uses example.com if that's not set. Ideally because it's a local route it should be a relative url. Perhaps this is a bug?

from turbo-rails.

fa11enangel avatar fa11enangel commented on August 10, 2024

Setting config.action_controller.default_url_options may have side effects to your project, which you don't expect. url_for is a solution for me too without changing global configuration, which change routing behaviour in some unexpected way for me.

As all related issues and pull-requests were closed due to inactivity, there is no good solution for this issue except these two workarounds.

I've written a blog post regarding Default URL Options to better understand the different settings, which might be the reason tool.

The analysis of my problems with ActiveStorage are documented here: Define Default URL for ActiveStorage to fix Mixed Content Error

from turbo-rails.

hdaniel avatar hdaniel commented on August 10, 2024

Confirming this is still an issue that can cause active storage to redirect to example.org.

from turbo-rails.

wwvuillemot avatar wwvuillemot commented on August 10, 2024

Same; having this issue with ActsAsTenant, ActiveJob, ActiveStorage ....

from turbo-rails.

fa11enangel avatar fa11enangel commented on August 10, 2024

Same; having this issue with ActsAsTenant, ActiveJob, ActiveStorage ....

Try to check the different settings you have in your project. If you set the wrong configuration/param, they will have side effects on other parts of your application like ActiveJob, ActiveStorage, etc. Check my blog post, where the setup for ActiveStorage etc is explained: Default URL Options.

I had the same problems with ActiveStorage and tried to explain it here: Define Default URL for ActiveStorage to fix Mixed Content Error

from turbo-rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.