I am having trouble with all my asset helpers except for image_tag
for some reason. They are all generating the wrong paths. I am using Rails 4.0.0 and Ruby 2.0.0. My images are in /app/assets/images
e.g.
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 given the wrong URL... I need /assets/this.png
which only seems to be generated by image_tag
This happens in .haml
, .scss
, .erb
alike.
I can't find the solution to this problem... anybody seen this before and have the answer?
The require_tree directive tells Sprockets to recursively include all JavaScript files in the specified directory into the output. These paths must be specified relative to the manifest file.
rails assets:precompile is the task that does the compilation (concatenation, minification, and preprocessing). When the task is run, Rails first looks at the files in the config.assets.precompile array. By default, this array includes application.js and application.css .
The Rails asset pipeline provides an assets:precompile rake task to allow assets to be compiled and cached up front rather than compiled every time the app boots. There are two ways you can use the asset pipeline on Heroku. Compiling assets locally. Compiling assets during slug compilation.
The asset pipeline provides a framework to concatenate and minify or compress JavaScript and CSS assets. It also adds the ability to write these assets in other languages such as CoffeeScript, Sass and ERB. Prior to Rails 3.1 these features were added through third-party Ruby libraries such as Jammit and Sprockets.
I was having the same issue as you. I followed this thread and was able to solve it by clearing the tmp
cache.
$ rake tmp:cache:clear
Hope it helps.
image_path has been deprecated.check the 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
For image_tag, the docs clearly says Returns an HTML image tag for the source. The source can be a full path or a file.
So in that case path it points to is /assets/file_name.png
whereas for **image_path**
Computes the path to an image asset in the public images directory. Full paths from the document root will be passed through.`
Path is /images/filename.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With