B
B
bismoney2015-10-22 16:29:11
Ruby on Rails
bismoney, 2015-10-22 16:29:11

Ruby and Rails image output?

Hello again, a lot of questions just about RoR)
I have a slim template engine.
I added a paperclip image to the post
. If I output the path to the image, for example,
p = post.photo.url
then it will be displayed as

<p>/system/posts/photo/000/000/001/original/b4d18d7753eaa35ca60c2e591d8889d2.jpg?1445519888</p>

What if I need something like this
div class="test" style="background-image: url(post.photo.url)"

So he outputs
<div class="test" style="background-image: url(post.photo.url)">

How to insert in the slim template so that it displays the image path in the background-image: url()
And another question is how to display the full path with the domain?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CapeRatel, 2015-10-22
@bismoney

.test(style="background-image: url(#{post.photo.url})")

Interpolation my friend, the very basics.
About paths
api.rubyonrails.org/classes/ActionView/Helpers/Ass...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question