Asset Routing Assistants resolving the wrong URL or path

For some reason, I am having problems with all of my asset assistants except image_tag. All of them give rise to wrong paths. I am using Rails 4.0.0 and Ruby 2.0.0. My images are in/app/assets/images

eg.

asset_url('this.png')    # -> /this.png
asset_path('this.png')   # -> /this.png
image_url('this.png')    # -> /images/this.png
image_path('this.png')   # -> /images/this.png
image-url('this.png')    # -> /images/this.png
asset-url('this.png')    # -> /this.png
image_tag('this.png')    # -> <img ... src="/assets/this.png" /> <- only correct one

I am always assigned the wrong URL ... I need /assets/this.pngone that is only createdimage_tag

This occurs in the .haml, .scss, .erb.

I can not find a solution to this problem ... has anyone seen this before and received an answer?

+4
source share
3 answers

, . , tmp.

$ rake tmp:cache:clear

, .

+3

image_path . ApiDock

Method deprecated or moved
This method is deprecated or moved on the latest stable version. The last existing version (v3.2.13) is shown here.

These similar methods exist in v4.0.2:

ActionView::Helpers::AssetUrlHelper#image_path

image_tag docs Returns an HTML image tag for the source. The source can be a full path or a file. , , , /assets/file_name.png

whereas for **image_path** . . ` -/images/filename.png

+1

Rail 4.2.1. :

body
{
    background: #EFEFEF image-url('layouts/background.jpg') no-repeat top center fixed;
}

SASS :

body
{
    background: #EFEFEF url('/images/layouts/background.jpg') no-repeat top center fixed;
}

, , ​​! , , , layout, layouts.

, url(/assets/layout/background.jpg) , .

12NOV2015 , image_tag(). ( ), ".png" . , , -, . ".png" , image_tag() .

This is ridiculous. Not sure why it is returning to some non-standard path ( /imagesinstead /assets) instead of throwing an exception (but I also did not bother to look at the source).

0
source

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


All Articles