Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Will_paginate barfs in project with no ActiveRecord

#221

If you try to use will_paginate in a Rails project that does not use ActiveRecord, for example:

Rails::Initializer.run do |config|

#

  1. Project is not currently using a database, so...

config.frameworks -= [ :active_record ]

end

your the server will die on startup with this error:

/Users/lori/Documents/workspaces/codegear/qconrails/vendor/rails/activesupport/lib/active_support/dependencies.rb:413:in `to_constant_name': Anonymous modules have no name to be referenced by (ArgumentError)

from /Users/lori/Documents/workspaces/codegear/qconrails/vendor/rails/activesupport/lib/active_support/dependencies.rb:225:in `qualified_name_for'

from /Users/lori/Documents/workspaces/codegear/qconrails/vendor/rails/activesupport/lib/active_support/dependencies.rb:490:in `const_missing'

from /Users/lori/Documents/workspaces/codegear/qconrails/vendor/plugins/will_paginate/lib/will_paginate.rb:32:in `enable_activerecord'

from /Users/lori/Documents/workspaces/codegear/qconrails/vendor/plugins/will_paginate/lib/will_paginate.rb:15:in `enable'

from /Users/lori/Documents/workspaces/codegear/qconrails/vendor/plugins/will_paginate/init.rb:2:in `evaluate_init_rb'

from /Users/lori/Documents/workspaces/codegear/qconrails/script/../config/../vendor/rails/railties/lib/rails/plugin.rb:95:in `evaluate_init_rb'

from /Users/lori/Documents/workspaces/codegear/qconrails/vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'

from /Users/lori/Documents/workspaces/codegear/qconrails/script/../config/../vendor/rails/railties/lib/rails/plugin.rb:91:in `evaluate_init_rb'

... 35 levels...

from /Users/lori/Documents/workspaces/codegear/qconrails/vendor/rails/railties/lib/commands/server.rb:39

from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'

from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

from /Users/lori/Documents/workspaces/codegear/qconrails/script/server:3

I don't really have a patch, because I couldn't figure out how to write a test for it. I worked around the problem by commenting out "enable_activerecord"

module WillPaginate

class << self

  1. shortcut for enable_actionpack; enable_activerecord

def enable

enable_actionpack

  1. enable_activerecord

end

Reported by ronin-20496 (at lighthouseapp) · May 16th, 2008 @ 05:21 PM

State: invalid
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Mislav
    Mislav
    • State changed from new to invalid
    • Assigned user changed from Chris Wanstrath to Mislav

    Use the latest gem. You can see by this code that it doesn't call WillPaginate.enable unless both ActiveRecord and ActionController are present.

    If you don't use ActiveRecord, just call

    WillPaginate::enable_actionpack
    

    yourself after requiring the library from the gem.

    June 11th, 2008 @ 02:09 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.