Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:47:43+00:00 2026-06-10T14:47:43+00:00

I have made a custom link renderer for will_paginate and have placed the code

  • 0

I have made a custom link renderer for will_paginate and have placed the code in lib/my_link_renderer.rb

require 'will_paginate/view_helpers/link_renderer'
require 'will_paginate/view_helpers/action_view'

class MyLinkRenderer < WillPaginate::ActionView::LinkRenderer
  include ListsHelper
  def to_html
    html = pagination.map do |item|
      item.is_a?(Fixnum) ?
        page_number(item) :
        send(item)
    end.join(@options[:link_separator])
    html << @options[:extra_html] if @options[:extra_html]

    @options[:container] ? html_container(html) : html
  end
end

Then I use it like so:

  <%= will_paginate @stuff, 
        :previous_label=>'<input class="btn" type="button" value="Previous"/>',
        :next_label=>'<input class="btn" type="button" value="Next" />',
        :extra_html=>a_helper,
        :renderer => 'WillPaginate::ActionView::MyLinkRenderer'
  %>

It works the first time but the second time I get a uninitialized constant WillPaginate::ActionView::MyLinkRenderer error. I believe I am loading files from lib into my application correctly in my config/application.rb:

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += Dir["#{config.root}/lib/**/"]

I get the same problem in the console.

system :001 > WillPaginate::ActionView::MyLinkRenderer
 => MyLinkRenderer 
system :002 > WillPaginate::ActionView::MyLinkRenderer
NameError: uninitialized constant WillPaginate::ActionView::MyLinkRenderer

Suspect this has something to do with how rails autoloads things. Should I not be using autoload? Should I be explictly requiring ‘./lib/my_link_renderer’?

I should note this only happens on my production server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:47:45+00:00Added an answer on June 10, 2026 at 2:47 pm

    Your MyLinkRenderer class isn’t in the WillPaginate::ActionView module, so referring to it as WillPaginate::ActionView::MyLinkRenderer should never work.

    You should either refer to it as MyLinkRenderer (without the module name) or define it to be in that module, and move it to lib/will_paginate/action_view/my_link_renderer.rb:

    module WillPaginate::ActionView
      class MyLinkRenderer < LinkRenderer
        …
      end
    end
    

    The fact that it works first time is a quirk of the way Rails uses const_missing to implement autoloading. If you’re curious, see this answer: https://stackoverflow.com/a/10633531/5168

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have images placed in following path res>drawable>Images>Currencies>[All images] I have made a custom
I have made a custom dialog window that inherits ChildWindow public partial class InputWindow
Have this code: <sj:head compressed=false jqueryui=true jquerytheme=custom/> <s:url id=link action=ABC namespace=/DEF escapeAmp=false/> <sj:a openDialog=_dialog
I have cells in UITableView , I have made custom frame for the label
I have made a custom form in a module where I have used a
I have made a custom formwizard and incorporated it into my admin interface. Basically
I have made my custom module in magento, in which I have set discount
I have made a custom suface button according this example: <Button> <Button.Template> <ControlTemplate TargetType=Button>
i have made my custom Static Library (.a) successfully. i have tested it in
I have made a custom NSView and have implemented the keyDown: method. However, when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.