Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

will_paginate initializer now throws NameError error #165

Closed
npadgett opened this Issue · 8 comments

5 participants

@npadgett

My initializers file is named 'config/initializers/will_paginate.rb' and includes the following.

WillPaginate::ViewHelpers.pagination_options[:previous_label] = '‹'
WillPaginate::ViewHelpers.pagination_options[:next_label] = '›'

This is the error that is thrown when I run 'rails s':

/Users/ysername/projects/project/config/initializers/will_paginate.rb:3: uninitialized constant WillPaginate::ViewHelpers (NameError)

This occurs with will_paginate 3.0.pre4 and 3.0.0.

I'm using Rails 3.0.10.

@npadgett

I had to add "require 'will_paginate/view_helpers'" to the top of my initializers file to get this to work. Please update your documentation.

@mislav
Owner
@npadgett

mislav,

With rails 3.0.10 installed, here are the steps I ran to replicate the issue.

rails new project_name
cd project_name
echo "gem 'will_paginate', '3.0.0'" >> Gemfile
bundle install
echo "WillPaginate::ViewHelpers.pagination_options[:previous_label] = '‹'" >> config/initializers/will_paginate.rb
rails s

Here is the output from the server.

=> Booting WEBrick
=> Rails 3.0.10 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/nickpadgett/projects/project_name/config/initializers/will_paginate.rb:1: uninitialized constant WillPaginate::ViewHelpers (NameError)
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/engine.rb:201
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/engine.rb:200:in each'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/engine.rb:200
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/initializable.rb:25:in
instance_exec'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/initializable.rb:25:in run'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/initializable.rb:50:in
run_initializers'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/initializable.rb:49:in each'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/initializable.rb:49:in
run_initializers'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/application.rb:134:in initialize!'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/application.rb:77:in
send'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/railties-3.0.10/lib/rails/application.rb:77:in method_missing'
from /Users/nickpadgett/projects/project_name/config/environment.rb:5
from /Users/nickpadgett/projects/project_name/config.ru:3:in
require'
from /Users/nickpadgett/projects/project_name/config.ru:3
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/rack-1.2.3/lib/rack/builder.rb:46:in instance_eval'
from /Users/nickpadgett/.rvm/gems/ruby-1.8.7-p302/gems/rack-1.2.3/lib/rack/builder.rb:46:in
initialize'
from /Users/nickpadgett/projects/project_name/config.ru:1:in `new'
from /Users/nickpadgett/projects/project_name/config.ru:1

Here's the contents of my Gemfile.lock:

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.10)
actionpack (= 3.0.10)
mail (~> 2.2.19)
actionpack (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.10)
activesupport (= 3.0.10)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activeresource (3.0.10)
activemodel (= 3.0.10)
activesupport (= 3.0.10)
activesupport (3.0.10)
arel (2.0.10)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.5.0)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
polyglot (0.3.2)
rack (1.2.3)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.10)
actionmailer (= 3.0.10)
actionpack (= 3.0.10)
activerecord (= 3.0.10)
activeresource (= 3.0.10)
activesupport (= 3.0.10)
bundler (~> 1.0)
railties (= 3.0.10)
railties (3.0.10)
actionpack (= 3.0.10)
activesupport (= 3.0.10)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (~> 0.14.4)
rake (0.9.2)
rdoc (3.9.2)
sqlite3 (1.3.4)
thor (0.14.6)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.29)
will_paginate (3.0.0)

PLATFORMS
ruby

DEPENDENCIES
rails (= 3.0.10)
sqlite3
will_paginate (= 3.0.0)

I will investigate the i18n approach.

@kron4eg

I have similar error

from /gems/actionpack-3.0.10/lib/action_view/base.rb:209:in process_view_paths': uninitialized constant WillPaginate::ViewHelpers::ActionView::PathSet (NameError)
from /gems/actionpack-3.0.10/lib/abstract_controller/view_paths.rb:65:in
view_paths='

in my code I've tried to run this.
ActionController::Base.view_paths += ['some array with view paths']

@npadgett

I successfully added the yml below to config/locales/en.yml and no longer need config/initializers/will_paginate.rb. Thanks for the suggestion.

en:
will_paginate:
previous_label: '‹'
next_label: '›'

@mislav mislav closed this in be12b56
@mislav
Owner

Fixed. Until the next bugfix release, you simply need to require 'will_paginate/view_helpers' in your initializers.

@wxianfeng

have same problem, must
require 'will_paginate/view_helpers'
in will_paginate.rb

@frankel

plus 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.