Using the carrierwave gem to generate various versions of images, these can be invoked to generate the required image by referring to its version name
style='background: url(<%= pict.image_url(:small).to_s %>);'
Integrating these to a framework, such as foundation, that handles the viewports
<div class='show-for-small-only'>
<%= render partial: 'items', locals: { size: 'small'} %>
</div>
<div class='show-for-medium-only'>
<%= render partial: 'items', locals: { size: 'medium'} %>
</div>
How can one invoke the local as a symbol, as the following generates a syntaxic error
style='background: url(<%= pict.image_url(:#{size}).to_s %>);'
the proper call has two sets of renderings and thus the inner one requires double quotes for interpretation:
style='background: url(<%= pict.image_url("#{size.to_sym}").to_s %>);'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.