Paginate causes unitialized constant error

Earlier this week, I posted a question about scaffold causing an
unitialized constant. As no one seemed to have any information, I
started coding without the scaffolding. I’m now getting the error again.

In my controller, I started with the following line of code in a list
type method:
@quotes = Quotes.find :all

This works fine. As there are many quotes in the database, however, I
replaced it with the following line:
@quote_pages, @quotes = paginate(:quotes, :order => “author”)

This was the ONLY change. Immediately, my error came back. For those
that didn’t see the original post, here’s the error that is returned:


uninitialized constant Quote

RAILS_ROOT: script/…/config/…
Application Trace | Framework Trace | Full Trace

/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
const_missing' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:inconst_missing’
/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in
constantize' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:inconstantize’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:194:in
paginator_and_collection_for' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:inpaginate’
app/controllers/admin_controller.rb:6:in `quotes’

/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
const_missing' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:inconst_missing’
/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in
constantize' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:inconstantize’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:194:in
paginator_and_collection_for' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:inpaginate’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
send' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:inperform_action_without_filters’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:in
perform_action_without_benchmark' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr//lib/ruby/1.8/benchmark.rb:293:in measure' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:inperform_action_without_rescue’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:in
perform_action' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:insend’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
process_without_filters' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:inprocess_without_session_management_support’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:in
process' /usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:indispatch’
/usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in
handle_dispatch' /usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:inservice’
/usr//lib/ruby/1.8/webrick/httpserver.rb:104:in service' /usr//lib/ruby/1.8/webrick/httpserver.rb:65:inrun’
/usr//lib/ruby/1.8/webrick/server.rb:173:in start_thread' /usr//lib/ruby/1.8/webrick/server.rb:162:instart’
/usr//lib/ruby/1.8/webrick/server.rb:162:in start_thread' /usr//lib/ruby/1.8/webrick/server.rb:95:instart’
/usr//lib/ruby/1.8/webrick/server.rb:92:in each' /usr//lib/ruby/1.8/webrick/server.rb:92:instart’
/usr//lib/ruby/1.8/webrick/server.rb:23:in start' /usr//lib/ruby/1.8/webrick/server.rb:82:instart’
/usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in
dispatch' /usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59 /usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
/usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:inrequire’
/usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
/usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' /usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require’
script/server:3

/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:123:in
const_missing' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:131:inconst_missing’
/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/inflector.rb:161:in
constantize' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/core_ext/string/inflections.rb:59:inconstantize’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:194:in
paginator_and_collection_for' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/pagination.rb:129:inpaginate’
app/controllers/admin_controller.rb:6:in quotes' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:insend’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:941:in
perform_action_without_filters' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:368:inperform_action_without_benchmark’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr//lib/ruby/1.8/benchmark.rb:293:inmeasure’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/benchmarking.rb:69:in
perform_action_without_rescue' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/rescue.rb:82:inperform_action’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:in
send' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/base.rb:408:inprocess_without_filters’
/usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/filters.rb:377:in
process_without_session_management_support' /usr//lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/session_management.rb:117:inprocess’
/usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in
dispatch' /usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:inhandle_dispatch’
/usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in
service' /usr//lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
/usr//lib/ruby/1.8/webrick/httpserver.rb:65:in run' /usr//lib/ruby/1.8/webrick/server.rb:173:instart_thread’
/usr//lib/ruby/1.8/webrick/server.rb:162:in start' /usr//lib/ruby/1.8/webrick/server.rb:162:instart_thread’
/usr//lib/ruby/1.8/webrick/server.rb:95:in start' /usr//lib/ruby/1.8/webrick/server.rb:92:ineach’
/usr//lib/ruby/1.8/webrick/server.rb:92:in start' /usr//lib/ruby/1.8/webrick/server.rb:23:instart’
/usr//lib/ruby/1.8/webrick/server.rb:82:in start' /usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:indispatch’
/usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
/usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' /usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
/usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
require' /usr//lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30 /usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
/usr//lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in require' /usr//lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:inrequire’
script/server:3

This error occured while loading the following files:
quote.rb


I haven’t a clue what might be wrong. Can anybody suggest something for
me?

Thanks in advance
—Michael

Michael S. wrote:

Earlier this week, I posted a question about scaffold causing an
unitialized constant. As no one seemed to have any information, I
started coding without the scaffolding. I’m now getting the error again.

In my controller, I started with the following line of code in a list
type method:
@quotes = Quotes.find :all

Your model “Quotes” is plural, normally models are singular
(convention)

This works fine. As there are many quotes in the database, however, I
replaced it with the following line:
@quote_pages, @quotes = paginate(:quotes, :order => “author”)

I think that paginate follow the convention and convert :quotes in
model Quote (singular). You can see :singular_name or :class_name
paginate options in
http://api.rubyonrails.org/classes/ActionController/Pagination.html#M000130

Regards!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs