I have the following js in my assets/javascript
jQuery ->
if $('.pagination').length
$(window).scroll ->
url = $('.pagination .next_page').attr('href')
if url && $(window).scrollTop() > $(document).height() - $(window).height() - 50
$('.pagination').html('<img src="images/spinner.gif" />')
$.getScript(url)
$(window).scroll()
Here I am calling for a spinner animation, but is not fetched on localhost.
No route matches [GET] "/images/spinner.gif"
I have already ran
rake assets:precompile:all RAILS_ENV=development
and my image is properly placed in assets/images (and in public) So this makes me think that the way I call for this image must be wrong.
First of all have a read at
rails asset pipelineand read difference between developement and production way of serving assets this will help you understand how the assets are servedIf you add an erb extension to a JavaScript asset, making it something such as application.js.erb, then you can use the asset_path helper in your JavaScript code: