Rails newbie can't initialize a new Paginator object


#1

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:inlist’
#{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:insend’
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:inperform_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:inmeasure’
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:inperform_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:inprocess_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:indispatch’
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:inservice’
c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
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:instart’
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:instart’
c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in each' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:instart’
c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in start' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:instart’
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:inrequire__’
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:inrequire’
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:inrequire’
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:inlist’
#{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:insend’
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:inperform_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:inmeasure’
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:inperform_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:inprocess_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:indispatch’
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:inservice’
c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in service' c:/programfiles/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
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:instart’
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:instart’
c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in each' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:instart’
c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:in start' c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:79:instart’
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:inrequire__’
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:inrequire’
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:inrequire’
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


#2

Pagenator should be Paginator, perhaps?

– Wes

On 3/21/06, Larry B. removed_email_address@domain.invalid wrote:

NOTE: @params[:search_results] is an Array of product_data objects

 # I've tried both:

exception from ruby. Basically, ruby can’t seem to load the Paginator
Stack trace
#{RAILS_ROOT}/app/controllers/product_datum_controller.rb:28:in list' /lib/action_controller/base.rb:853:in c:/programfiles/ruby/lib/ruby/gems/1.8/gems/actionpack-1.11.2process_without_session_management_support’
/lib/webrick_server.rb:83:in
c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start’

#{RAILS_ROOT}/app/controllers/product_datum_controller.rb:28:in list'perform_action_without_benchmark’
/lib/action_controller/rescue.rb:82:in
c:/programfiles/ruby/lib/ruby/gems/1.8/gems/rails-1.0.0
c:/programfiles/ruby/lib/ruby/1.8/webrick/server.rb:155:in
/lib/webrick_server.rb:69:in
/lib/active_support/dependencies.rb:214:in
/lib/active_support/dependencies.rb:214:in
removed_email_address@domain.invalid
http://lists.rubyonrails.org/mailman/listinfo/rails

-- Wes