Skip to content

Commit

Permalink
Use autoloading in Railtie so that framework loading isn't triggered …
Browse files Browse the repository at this point in the history
…by will_paginate
  • Loading branch information
matthuhiggins committed Oct 11, 2010
1 parent 3615938 commit 35216e2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/will_paginate/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
module WillPaginate
class Railtie < Rails::Railtie
initializer "will_paginate.active_record" do |app|
if defined? ::ActiveRecord
ActiveSupport.on_load :active_record do
require 'will_paginate/finders/active_record'
WillPaginate::Finders::ActiveRecord.enable!
end
end

initializer "will_paginate.action_dispatch" do |app|
if defined? ::ActionDispatch::ShowExceptions
ActiveSupport.on_load :action_controller do
ActionDispatch::ShowExceptions.rescue_responses['WillPaginate::InvalidPage'] = :not_found
end
end

initializer "will_paginate.action_view" do |app|
require 'will_paginate/view_helpers/action_view'
ActionView::Base.send(:include, WillPaginate::ViewHelpers::ActionView)
ActiveSupport.on_load :action_view do
require 'will_paginate/view_helpers/action_view'
include WillPaginate::ViewHelpers::ActionView
end
end
end
end

0 comments on commit 35216e2

Please sign in to comment.