Larry Barnett
2006-Mar-21 21:54 UTC
[Rails] Rails newbie can''t initialize a new Paginator object
Hi all, I''m using ruby 1.8.2-15 and a recent rails 1.0 download. I''m trying to implement the Classic/Custom pagination in a list action. Here''s my code: def list getSearchTerms # NOTE: @params[:search_results] is an Array of product_data objects # returned by a search action. @results = @params[:search_results] if @results.nil? then # The default list of all product_data @product_datum_pages, @product_data = paginate :product_data, :per_page => 10 else page = (@params[:page] ||= 1).to_i offset = (page - 1) * 10 # Note: ERROR OCCURS HERE # I''ve tried both: # ActionController::Pagenator.new and # ActionController::Pagination::Paginator.new # They don''t work either. @product_datum_pages = Pagenator.new self, @results.length, 10, page @product_data = @results[offset..(offset + 10 - 1)] end end When I try to run it, I get a "nameError: uninitialized constant" exception from ruby. Basically, ruby can''t seem to load the Paginator class. Looking at the library, this kinda makes sense, since Paginator is actually defined in pagination.rb. Is this: a) a RoR/ruby distro bug; b) a configuration error; or c) an application bug? Thanks, Larry Stack trace ===============================================================================uninitialized constant Pagenator RAILS_ROOT: ./script/../config/.. Application Trace | Framework Trace | Full Trace c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in `const_missing'' #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:28:in `list'' #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:106:in `search'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in `const_missing'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `send'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `perform_action_without_filters'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform_action_without_benchmark'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `measure'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform_action'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `send'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process_without_session_management_support'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in `process'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in `handle_dispatch'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service'' c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in `dispatch'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' script/server:3 c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:200:in `const_missing'' #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:28:in `list'' #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:106:in `search'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `send'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:853:in `perform_action_without_filters'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/filters.rb:332:in `perform_action_without_benchmark'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `measure'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/benchmarking.rb:69:in `perform_action_without_rescue'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/rescue.rb:82:in `perform_action'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `send'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/base.rb:369:in `process_without_session_management_support'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2/lib/action_controller/session_management.rb:116:in `process'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/dispatcher.rb:38:in `dispatch'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:117:in `handle_dispatch'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:83:in `service'' c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/webrick_server.rb:69:in `dispatch'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/servers/webrick.rb:59 c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/server.rb:28 c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require'' script/server:3 This error occured while loading the following files: pagenator.rb -- Posted via http://www.ruby-forum.com/.
Wes Garrison
2006-Mar-21 22:00 UTC
[Rails] Rails newbie can''t initialize a new Paginator object
Pagenator should be Paginator, perhaps? -- Wes On 3/21/06, Larry Barnett <lbarnett@palamida.com> wrote:> > Hi all, > > I''m using ruby 1.8.2-15 and a recent rails 1.0 download. > > I''m trying to implement the Classic/Custom pagination in a list action. > Here''s my code: > > def list > getSearchTerms > # NOTE: @params[:search_results] is an Array of product_data objects > # returned by a search action. > @results = @params[:search_results] > if @results.nil? then > # The default list of all product_data > @product_datum_pages, @product_data = paginate :product_data, > :per_page => 10 > else > page = (@params[:page] ||= 1).to_i > offset = (page - 1) * 10 > # Note: ERROR OCCURS HERE > # I''ve tried both: > # ActionController::Pagenator.new and > # ActionController::Pagination::Paginator.new > # They don''t work either. > @product_datum_pages = Pagenator.new self, @results.length, 10, > page > @product_data = @results[offset..(offset + 10 - 1)] > end > end > > When I try to run it, I get a "nameError: uninitialized constant" > exception from ruby. Basically, ruby can''t seem to load the Paginator > class. Looking at the library, this kinda makes sense, since Paginator > is actually defined in pagination.rb. Is this: > a) a RoR/ruby distro bug; > b) a configuration error; or > c) an application bug? > > Thanks, > > Larry > > Stack trace > > ===============================================================================> uninitialized constant Pagenator > > RAILS_ROOT: ./script/../config/.. > Application Trace | Framework Trace | Full Trace > > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5 > /lib/active_support/dependencies.rb:200:in > `const_missing'' > #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:28:in `list'' > #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:106:in > `search'' > > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5 > /lib/active_support/dependencies.rb:200:in > `const_missing'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:853:in > `send'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:853:in > `perform_action_without_filters'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/filters.rb:332:in > `perform_action_without_benchmark'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/benchmarking.rb:69:in > `perform_action_without_rescue'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/benchmarking.rb:69:in > `measure'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/benchmarking.rb:69:in > `perform_action_without_rescue'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/rescue.rb:82:in > `perform_action'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:369:in > `send'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:369:in > `process_without_session_management_support'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/session_management.rb:116:in > `process'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/dispatcher.rb:38:in > `dispatch'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/webrick_server.rb:117:in > `handle_dispatch'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/webrick_server.rb:83:in > `service'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:155:in > `start_thread'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in > `start_thread'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/webrick_server.rb:69:in > `dispatch'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/commands/servers/webrick.rb:59 > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require__'' > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5 > /lib/active_support/dependencies.rb:214:in > `require'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/commands/server.rb:28 > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require__'' > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5 > /lib/active_support/dependencies.rb:214:in > `require'' > script/server:3 > > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5 > /lib/active_support/dependencies.rb:200:in > `const_missing'' > #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:28:in `list'' > #{RAILS_ROOT}/app/controllers/product_datum_controller.rb:106:in > `search'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:853:in > `send'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:853:in > `perform_action_without_filters'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/filters.rb:332:in > `perform_action_without_benchmark'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/benchmarking.rb:69:in > `perform_action_without_rescue'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/benchmarking.rb:69:in > `measure'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/benchmarking.rb:69:in > `perform_action_without_rescue'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/rescue.rb:82:in > `perform_action'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:369:in > `send'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/base.rb:369:in > `process_without_session_management_support'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2 > /lib/action_controller/session_management.rb:116:in > `process'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/dispatcher.rb:38:in > `dispatch'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/webrick_server.rb:117:in > `handle_dispatch'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/webrick_server.rb:83:in > `service'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:155:in > `start_thread'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:144:in > `start_thread'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' > c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/webrick_server.rb:69:in > `dispatch'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/commands/servers/webrick.rb:59 > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require__'' > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5 > /lib/active_support/dependencies.rb:214:in > `require'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0 > /lib/commands/server.rb:28 > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require__'' > > c:/programfiles/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require'' > c:/programfiles/ruby/lib/ruby/gems/1.8/gems/activesupport-1.2.5 > /lib/active_support/dependencies.rb:214:in > `require'' > script/server:3 > > This error occured while loading the following files: > pagenator.rb > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- -- Wes -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060321/1f6dc9bc/attachment.html
Kevin Skoglund
2006-Mar-21 22:33 UTC
[Rails] Re: Rails newbie can''t initialize a new Paginator object
Take at look at this page: http://wiki.rubyonrails.org/rails/pages/ HowtoPagination In the code you sent, you misspelled "Paginator". That might be your problem. HTH, Kevin Skoglund On Mar 21, 2006, at 1:56 PM, rails-request@lists.rubyonrails.org wrote:> From: Larry Barnett <lbarnett@palamida.com> > Date: March 21, 2006 1:54:22 PM PST > To: rails@lists.rubyonrails.org > Subject: [Rails] Rails newbie can''t initialize a new Paginator object > Reply-To: rails@lists.rubyonrails.org > > > Hi all, > > I''m using ruby 1.8.2-15 and a recent rails 1.0 download. > > I''m trying to implement the Classic/Custom pagination in a list > action. > Here''s my code: > > def list > getSearchTerms > # NOTE: @params[:search_results] is an Array of product_data > objects > # returned by a search action. > @results = @params[:search_results] > if @results.nil? then > # The default list of all product_data > @product_datum_pages, @product_data = paginate :product_data, > :per_page => 10 > else > page = (@params[:page] ||= 1).to_i > offset = (page - 1) * 10 > # Note: ERROR OCCURS HERE > # I''ve tried both: > # ActionController::Pagenator.new and > # ActionController::Pagination::Paginator.new > # They don''t work either. > @product_datum_pages = Pagenator.new self, @results.length, 10, > page > @product_data = @results[offset..(offset + 10 - 1)] > end > end > > When I try to run it, I get a "nameError: uninitialized constant" > exception from ruby. Basically, ruby can''t seem to load the Paginator > class. Looking at the library, this kinda makes sense, since Paginator > is actually defined in pagination.rb. Is this: > a) a RoR/ruby distro bug; > b) a configuration error; or > c) an application bug? > > Thanks, > > Larry