新版本will_paginate的安装和使用

SVN方式的安装已经不被推荐了,新的will_paginate采用Gem安装。
gem install mislav-will_paginate --source http://gems.github.com 

成功后的提示信息如下:
Successfully installed mislav-will_paginate-2.3.2
Installing ri documentation for mislav-will_paginate-2.3.2...
Installing RDoc documentation for mislav-will_paginate-2.3.2...

升级也一样,只需要将上面的install改为update.
安装之后需要修改config/environment.rb文件
RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  #....
end
require 'will_paginate'

注意:必须在Rails::Initializer之后加入will_paginate.

这样总是安装最后的版本,如果需要安装指定的版本,可以这样:
# choose one of the following constraints:
gem 'mislav-will_paginate', '2.1.0'
gem 'mislav-will_paginate', '>=2.1.0'
gem 'mislav-will_paginate', '~>2.1' # this will load any 2.x version (greater or equal to 2.1),
                                    # but not 3.x

# finally, load the library
require 'will_paginate'


在will_paginate的wiki上还介绍了几种安装方法,详情请看 http://github.com/mislav/will_paginate/wikis

你可能感兴趣的:(SVN,ide,Ruby,Rails)