Difference between sass-rails helpers "image_url" and "asset_url" in rails 4.0?

I have jpg in the my / app / assets / images directory and I use it as a background with the following CSS.

body { background-image: image_url('metal_texture.jpg') } 

The asset_url helper also works in this case. Since the Rails 4 pipeline does not care about which directory in / app / assets is placed in the file, is there any reason to use image_url vs asset_url?

0
source share
2 answers

Source code: image_url , asset_url

image_url actually calls asset_url , passing one specific option: {type: :image} And compute_asset_path extraction finds the resource directory based on this option[:type]

+2
source

There is currently no difference between image-url and asset-url (underlined in Ruby, ported to Sass).

image-url calls the asset-url method that defines {type: image}

You can use asset-url when you don't know the type of asset.

0
source

Source: https://habr.com/ru/post/1247500/


All Articles