rails / tailwindcss-rails

Other
1.39k stars 170 forks source link

bg-[url(...)] not working with rails_blob_url (active_storage) #284

Closed sbounmy closed 10 months ago

sbounmy commented 10 months ago

I have a rails 7 app running with tailwindcss-rails and I am trying to display a background image (cover) using bg-[url(...)]

But it doesnt work with rails 7 active_storage Seems like the rails_blob_url is not being recognized by tailwindcss-rails...

I have an html.erb displaying :

<div class="h-24 w-fullbg-[url(https://placekitten.com/1400)]bg-no-repeat"></div>
<div class="w-full h-24 bg-no-repeat bg-[url(<%= rails_blob_url(current_house.hero_image) -%>)]"></div>
<!-- <div class="w-full h-24 bg-no-repeat bg-[url(http://localhost:3000/rails/active_storage/blobs/redirect/eyJfcmFpbHMiOnsibWVzc2FnZSI6IkJBaHBIUT09IiwiZXhwIjpudWxsLCJwdXIiOiJibG9iX2lkIn19--1f68a32dc902558a4ee5a14ca06057885f50ca7d/01-liveroom.jpg)]"> </div>
 -->
<%= image_tag rails_blob_url(current_house.hero_image) -%>

First div shows the image correctly

Second div doesnt display anything (blank)

image_tag displayed correctly so the issue doesn't come from generated url