I've implemented 'endless scrolling' feature, which users use to keep scrolling down if there are more posts to show. I followed Railscasts, and it works great locally (javascripts and will-paginate gem). However, on the server, this feature is not working. All I see is simple pagination, and endless scrolling is not applied. I think it's related to compiling or preprocessing because javascript is working fine locally.
I've tried running bundle exec rake assets:precompile
locally, and deploying it.
Also, I tried running the same command on the server as well. The problem hasn't been solved yet.
Does anybody have a good explanation for the problem? Related files are located as follows:
- app/assets/javascripts/posts.js.coffee
- app/views/index.js.erb
Assume the contents in the js files are fine because the feature works greatly on the local server. I am almost sure that the source of problem is compilation.
UPDATE:
from Rails guide about assets pipeline http://guides.rubyonrails.org/asset_pipeline.html
When these files(coffescripts) are requested, they are processed by the processors provided
by the coffee-script and sass gems and then sent back to the browser
as JavaScript and CSS respectively.
This explains about the line in config/application.rb
Bundler.require *Rails.groups(:assets => %w(development test))
only loads gems from the assets group in your development and test environment.
This means that things like sass-rails and uglifier won't be available
in production, which then means that you won't be able to properly
compile/minify/whatever your assets on the fly in production
if you're making use of those gems.
and in Gemfile, I have
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
end
Does this mean that app/assets/javascripts/posts.js.coffee file wasn't compiled properly before being deployed and that was the problem?
Thank you very much in advance for your kind help.