Every repository with this icon (
Every repository with this icon (
Installation
There are three options when approaching will_paginate installation:
- use the gem (recommended);
- install as Rails plugin using git;
- download tarballs;
Which option to choose? If not sure, install the gem. Latest RubyGems are a stable and powerful platform for managing Ruby libraries on your system. Plugin installation is only recommended for advanced developers who want to track it using a vendor branch management tool or hack its source within their application.
If you want to get the latest and greatest code but don’t have git, see below for a way to download tarballs. However, if you are a Ruby developer I strongly recommend you to have git on your system not just because of will_paginate, but because most popular Ruby projects (including Rails) are now developed using git and hosted on GitHub.
Also:
- See the troubleshooting section.
- Read about the internals if you’re interested what happens when the library loads.
- Report bugs.
Using Rails 2.1 (or later) gem dependencies
To enable the library your Rails 2.1 (or later) project, use the gem configuration method in “config/environment.rb”
Rails::Initializer.run do |config|
config.gem 'will_paginate', :version => '~> 2.3.11', :source => 'http://gemcutter.org'
end
To install this gem (and all other missing gem dependencies), run rake gems:install (use sudo if necessary). Also, don’t forget to restart your webserver after editing environment.rb.
Installing the gem manually
First, ensure that you’re running at least RubyGems 1.3.2 (check gem -v if you’re not sure).
The will_paginate gem is hosted on Gemcutter. Add it to your gem sources (once per machine):
gem sources -a http://gemcutter.org
Install the library:
gem install will_paginate
To enable the library your Rails 2.0.x (or even 1.2.x) project, load it in “config/environment.rb”
Rails::Initializer.run do |config|
...
end
require "will_paginate"
Don’t put it before or inside the Rails::Initializer block because the Rails framework is not yet loaded at that point of execution.
That will always load the latest installed version of the gem. If you want to have control of the version loaded, you can use version constraints with the gem method:
# choose one of the following constraints:
gem 'mislav-will_paginate', '2.3.11'
gem 'mislav-will_paginate', '>= 2.3.11'
gem 'mislav-will_paginate', '~> 2.3.11' # this will load any 2.3.x version
# (greater or equal to 2.3.11), but not 2.4 or 3.x
# finally, load the library
require 'will_paginate'
Remember to restart your webserver after editing environment.rb to allow the changes to take effect.
Install as plugin using git
To continuously track will_paginate development, it’s probably best to install it as a plugin using some vendor branch management tool like Braid:
gem install evilchelu-braid
Using Braid to add a Rails plugin is simple:
# (make sure you've commited everything first)
braid add git://github.com/mislav/will_paginate.git -p
# braid performs its thing in "braids/track" branch;
# merge it in your master branch like so:
git merge braid/track
# now you should have the library in vendor/plugins/will_paginate
Alternative to Braid: if you’re using Rails 2.1 or later, you can simply use “script/plugin”. It will export all the code from GitHub into “vendor/plugins”
script/plugin install git://github.com/mislav/will_paginate.git
Export from GitHub as tarballs
Here is the download link for the latest state of the will_paginate master branch (.tar.gz archive). You can extract it into “vendor/plugins” directory manually (and rename it to “will_paginate”), or you could paste this in the console on a -nix system (requires wget):
mkdir vendor/plugins/will_paginate
wget -nv http://github.com/mislav/will_paginate/tarball/master -O- | \
tar xzv -C vendor/plugins/will_paginate --strip 1
on windows
wget http://github.com/mislav/will_paginate/tarball/master
then untar/zip it, drop it in vendor/plugins/will_paginate
This process is available as a Sake task.
sake -i http://pastie.org/161203.txt
sake will_paginate:install
To update the plugin (and you should do that regularly!), just repeat the above command (without mkdir). That will extract new files over the old ones. Or, you could use the above Sake task. It will not remove files that are no longer used, however. You can always make a clean install: remove “vendor/plugins/will_paginate” and start over from the top.
You can build a gem when you unzipped the tarball:
gem build will_paginate.gemspec






