Mic*_*ton 5 ruby-on-rails asset-pipeline
除了image_tag某些原因外,我的所有资产助手都遇到了麻烦.它们都在产生错误的路径.我使用的是Rails 4.0.0和Ruby 2.0.0.我的照片在/app/assets/images
例如
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
Run Code Online (Sandbox Code Playgroud)
我总是得到错误的URL ...我需要/assets/this.png它似乎只是由生成image_tag
这发生在.haml,.scss,.erb的一致好评.
我无法找到解决这个问题的方法......之前有人见过这个并得到答案吗?
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
Run Code Online (Sandbox Code Playgroud)
对于image_tag,文档清楚地说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
| 归档时间: |
|
| 查看次数: |
1510 次 |
| 最近记录: |