Skip to content

Installing without the Asset Pipeline

Ronald Chan edited this page Mar 9, 2012 · 2 revisions

To install this gem either for pre-Rails 3.1, or to install this gem in Rails 3.1+, but without using the assets pipeline, first install the gem, adding the following to your Gemfile

gem 'ajax_pagination'

Then run

bundle install

Next, generate the javascript and css files. If you have not already installed jquery-rails or jquery-historyjs, the javascript files associated with those gems also need to be generated.

rails generate jquery:install # generate jquery js files, if not previously installed
rails generate historyjs:install # generate History.js files, if not previously installed
rails generate ajax_pagination:assets # generates javascript and css files for this gem

The jquery-rails gem automatically adds its javascript files to be included using the javascript_include_tag(:defaults) method. If you not using this method call, jquery.js will also need to be included in your application.

Ensure that jquery.js, jquery_ujs.js, json2.js, history.js, history.adapter.jquery.js, jquery.ba-bbq.js, jquery.url.js and ajax_pagination.js files in the /public/javascripts/ directory are included in your application.

Also include /public/stylesheets/ajax_pagination.css in your application.

Note that the ajax_pagination.js file may change depending on your configuration in the initializer, and possibly the rails environment. If either of these changes, you may need to run the

rails generate ajax_pagination:assets

command again to update the javascript file.

An initializer is not necessary, but can be used to change the configuration when the defaults are not suitable. To create an initializer file, simply run:

bundle exec rails generate ajax_pagination:install

You new initializer can be found at config/initializers/ajax_pagination.rb.

For production, it may be useful to use an initializer and set:

  config.warnings = false

This is because if it is not set, the behaviour is dependent on the environment at the time the ajax_pagination:assets generator was run, which is likely to be development.