Comments (8)
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.
@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.
No, sorry. I'm just using url_for
right now.
from turbo-rails.
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.
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.
Confirming this is still an issue that can cause active storage to redirect to example.org.
from turbo-rails.
Same; having this issue with ActsAsTenant, ActiveJob, ActiveStorage ....
from turbo-rails.
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)
- Turbo Documentation need a "Broadcast" chatper
- Refresh broadcasts generated without changes
- Incompatible with Solid_Queue HOT 1
- turbo_frame_request_id safe operator in not handled correctly HOT 2
- Shouldn't broadcast refresh if streamables == [nil] HOT 1
- @npezza93 ActiveRecord::RecordNotFound in MembersController#edit_description
- FORM with an action URL containing a query param is not submitted. HOT 1
- Mixed Content Error with Turbo Drive
- OT: Attackers might be trying to steal your information from discuss.hotwire.dev HOT 2
- Turbo refresh can hijack user navigation HOT 3
- import "@hotwired/turbo-rails" errors HOT 1
- Using data-turbo-confirm on plain (non-form) buttons HOT 3
- Adding stimulus breaks a test HOT 1
- how do you install turboframes into a rails 5 project that migrated to rails 7 using only sprockets (skipping all the webpack & 6 bs)? HOT 2
- What are the controls effected before injecting `text/vnd.turbo-stream.html`?
- turbo_stream.remove_all Not generating proper selector for targets.
- idiomorph merges attributes on `<turbo-cable-stream-source>` and `connectedCallback()` doesn't run HOT 2
- Add morph to StreamActions HOT 5
- how do I batch multiple turbo stream broadcasts?
- <turbo-cable-stream-source> tag can affect visual layout HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbo-rails.