Skip to content

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

Closed
@sbounmy

Description

@sbounmy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions