I am having trouble with the paginate code and an sqlserver adapter. In the
generated scaffold there exists code like:
def list
@manager_pages, @managers = paginate :Manager, :per_page => 10
end
which works fine with the exact same table under a postgresql adapter;
however, with the sqlserver adapter I get the error attached below.
Also the show and edit features work correctly. If I change the method like:
def list
@managers = Manager.find_all
end
And make reasonable changes to list.rhtml it also works. So I am pretty sure
this is an issue with the sqlserver adapter. When I have time I will try to
address this issue; however, I am a rails newbie and I don''t have time
to
figure this out today.
Thanks for the wonderful framework,
Patrick
---------------------------------------------------------------
Error when using sqlserver adapter from http://127.0.0.1:3000/managers/list
NoMethodError in Managers#list
undefined method `[]'' for nil:NilClass
app/controllers/managers_controller.rb:8:in `list''
script/server:48
Show framework trace
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/connection_adapters/sqlserver_adapter.rb:293:in
`add_limit_with_offset!''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/base.rb:750:in
`add_limit!''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/base.rb:743:in
`construct_finder_sql''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/base.rb:334:in
`find''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/deprecated_finders.rb:37:in
`find_all''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/pagination.rb:161:in
`find_collection_for_pagination''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/pagination.rb:175:in
`paginator_and_collection_for''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/pagination.rb:111:in
`paginate''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:708:in
`send''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:708:in
`perform_action_without_filters''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/filters.rb:294:in
`perform_action_without_benchmark''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
`perform_action_without_rescue''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
`measure''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/benchmarking.rb:37:in
`perform_action_without_rescue''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/rescue.rb:79:in
`perform_action''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:330:in
`send''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:330:in
`process''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/base.rb:273:in
`process''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/dispatcher.rb:32:in
`dispatch''
D:/rails/tiff/public/dispatch.rb:10
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:189:in
`load''
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/dependencies.rb:189:in
`load''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/webrick_server.rb:82:in
`handle_dispatch''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/webrick_server.rb:35:in
`service''
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
C:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread''
C:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread''
C:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each''
C:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/webrick_server.rb:21:in
`dispatch''
Request
Parameters: None
Show session dump
---
flash: !ruby/hash:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[],
"Cache-Control"=>"no-cache"}
Show template parameters
-------------------------------------------------------
I have the following gems and the sqlserver DBI/ADO stuff installed:
actionmailer (0.9.1, 0.9.0, 0.8.1, 0.8.0)
actionpack (1.8.1, 1.8.0, 1.7.0, 1.6.0)
actionwebservice (0.7.1, 0.7.0, 0.6.2, 0.6.1)
activerecord (1.10.1, 1.10.0, 1.9.1, 1.9.0)
activesupport (1.0.4, 1.0.3, 1.0.2)
postgres-pr (0.4.0, 0.3.6)
rails (0.12.1, 0.12.0, 0.11.1, 0.11.0)
rake (0.5.3, 0.5.0, 0.4.15)
rubygems-update (0.8.10)
Patrick, Try adding a sort-by clause as well as the sort direction ASC or DESC (in caps). I had to add these in order to get paging to work in SQL Server. Hammed
<Wayne_Hearn-DYMqY+WieiM@public.gmane.org>
2005-Apr-21 18:44 UTC
RE: sqlserver adapter error with paginate
Checkout the bug Trac database, I posted one solution to this last
night.
-----Original Message-----
From: Patrick Hurley [mailto:phurley-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
Sent: Thursday, April 21, 2005 10:21 AM
To: rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
Subject: [Rails] sqlserver adapter error with paginate
I am having trouble with the paginate code and an sqlserver adapter. In
the generated scaffold there exists code like:
def list
@manager_pages, @managers = paginate :Manager, :per_page => 10
end
which works fine with the exact same table under a postgresql adapter;
however, with the sqlserver adapter I get the error attached below.
Also the show and edit features work correctly. If I change the method
like:
def list
@managers = Manager.find_all
end
And make reasonable changes to list.rhtml it also works. So I am pretty
sure this is an issue with the sqlserver adapter. When I have time I
will try to address this issue; however, I am a rails newbie and I
don''t
have time to figure this out today.
Thanks for the wonderful framework,
Patrick
---------------------------------------------------------------
Error when using sqlserver adapter from
http://127.0.0.1:3000/managers/list
NoMethodError in Managers#list
undefined method `[]'' for nil:NilClass
app/controllers/managers_controller.rb:8:in `list''
script/server:48
Show framework trace
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/con
nection_adapters/sqlserver_adapter.rb:293:in
`add_limit_with_offset!''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/bas
e.rb:750:in
`add_limit!''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/bas
e.rb:743:in
`construct_finder_sql''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/bas
e.rb:334:in
`find''
C:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.10.1/lib/active_record/dep
recated_finders.rb:37:in
`find_all''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/pa
gination.rb:161:in
`find_collection_for_pagination''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/pa
gination.rb:175:in
`paginator_and_collection_for''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/pa
gination.rb:111:in
`paginate''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/ba
se.rb:708:in
`send''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/ba
se.rb:708:in
`perform_action_without_filters''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/fi
lters.rb:294:in
`perform_action_without_benchmark''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/be
nchmarking.rb:37:in
`perform_action_without_rescue''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/be
nchmarking.rb:37:in
`measure''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/be
nchmarking.rb:37:in
`perform_action_without_rescue''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/re
scue.rb:79:in
`perform_action''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/ba
se.rb:330:in
`send''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/ba
se.rb:330:in
`process''
C:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.8.1/lib/action_controller/ba
se.rb:273:in
`process''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/dispatcher.rb:32:in
`dispatch''
D:/rails/tiff/public/dispatch.rb:10
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/de
pendencies.rb:189:in
`load''
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.0.4/lib/active_support/de
pendencies.rb:189:in
`load''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/webrick_server.rb:82:in
`handle_dispatch''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/webrick_server.rb:35:in
`service''
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service''
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run''
C:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread''
C:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread''
C:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each''
C:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
C:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start''
C:/ruby/lib/ruby/gems/1.8/gems/rails-0.12.1/lib/webrick_server.rb:21:in
`dispatch''
Request
Parameters: None
Show session dump
---
flash: !ruby/hash:ActionController::Flash::FlashHash {}
Response
Headers: {"cookie"=>[],
"Cache-Control"=>"no-cache"}
Show template parameters
-------------------------------------------------------
I have the following gems and the sqlserver DBI/ADO stuff installed:
actionmailer (0.9.1, 0.9.0, 0.8.1, 0.8.0) actionpack (1.8.1, 1.8.0,
1.7.0, 1.6.0) actionwebservice (0.7.1, 0.7.0, 0.6.2, 0.6.1) activerecord
(1.10.1, 1.10.0, 1.9.1, 1.9.0) activesupport (1.0.4, 1.0.3, 1.0.2)
postgres-pr (0.4.0, 0.3.6) rails (0.12.1, 0.12.0, 0.11.1, 0.11.0) rake
(0.5.3, 0.5.0, 0.4.15) rubygems-update (0.8.10)