To let rails automatically and correctly link assets (css/js/images) in most cases you want to use built in helpers. (Official documentation)

Image helpers

image_path

This returns the path to an image asset in app/assets/images.

image_path("edit.png") # => /assets/edit.png

image_url

This returns the full URL to an image asset in app/assets/images.

image_url("edit.png") # => http://www.example.com/assets/edit.png

image_tag

Use this helper if you want to include an <img src="" />-tag with the source set.

image_tag("icon.png") # => <img src="/assets/icon.png" alt="Icon" />

JavaScript helpers

javascript_include_tag

If you want to include a JavaScript-file in your view.

javascript_include_tag "application" # => <script src="/assets/application.js"></script>

javascript_path

This returns the path of your JavaScript-file.

javascript_path "application" # => /assets/application.js

javascript_url

This returns the full URL of your JavaScript-file.