josevalim/inherited_resources — Issue #196: has_scope :limit does not work with json
Author: Harlley
Created: 2012-01-20 16:04:32+00:00
State: open

I have this controller

class ClientsController < InheritedResources::Base
respond_to :json
has_scope :limit, :default => 10
end

When I access it on the browser **http://0.0.0.0:3000/clients.json?limit=2**, I get this error:

```text
ArgumentError in ClientsController#index

comparison of Fixnum with String failed

Rails.root: /home/01354488679/Dropbox/projetos/emailfreehost
Application Trace | Framework Trace | Full Trace

mongo (1.5.2) lib/mongo/cursor.rb:272:in `>'
mongo (1.5.2) lib/mongo/cursor.rb:272:in `batch_size'
mongo (1.5.2) lib/mongo/cursor.rb:80:in `initialize'
mongo (1.5.2) lib/mongo/collection.rb:236:in `new'
mongo (1.5.2) lib/mongo/collection.rb:236:in `find'
mongoid (2.4.1) lib/mongoid/collections/master.rb:25:in `block in find'
mongoid (2.4.1) lib/mongoid/collections/retry.rb:29:in `retry_on_connection_failure'
mongoid (2.4.1) lib/mongoid/collections/master.rb:24:in `find'
mongoid (2.4.1) lib/mongoid/collection.rb:42:in `find'
mongoid (2.4.1) lib/mongoid/contexts/mongo.rb:174:in `execute'
mongoid (2.4.1) lib/mongoid/contexts/mongo.rb:257:in `iterate'
mongoid (2.4.1) lib/mongoid/criteria.rb:145:in `block in each'
mongoid (2.4.1) lib/mongoid/criteria.rb:145:in `tap'
mongoid (2.4.1) lib/mongoid/criteria.rb:145:in `each'
mongoid (2.4.1) lib/mongoid/criteria.rb:278:in `entries'
mongoid (2.4.1) lib/mongoid/criteria.rb:278:in `as_json'
activesupport (3.1.3) lib/active_support/json/encoding.rb:47:in `block in encode'
activesupport (3.1.3) lib/active_support/json/encoding.rb:78:in `check_for_circular_references'
activesupport (3.1.3) lib/active_support/json/encoding.rb:46:in `encode'
activesupport (3.1.3) lib/active_support/json/encoding.rb:31:in `encode'
activesupport (3.1.3) lib/active_support/core_ext/object/to_json.rb:20:in `to_json'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:95:in `block in '
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:37:in `block in _handle_render_options'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:34:in `each'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:34:in `_handle_render_options'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:30:in `render_to_body'
actionpack (3.1.3) lib/action_controller/metal/compatibility.rb:43:in `render_to_body'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:99:in `render'
actionpack (3.1.3) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.1.3) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
activesupport (3.1.3) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:252:in `display'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:202:in `api_behavior'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:181:in `rescue in to_format'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:175:in `to_format'
responders (0.6.4) lib/responders/http_cache_responder.rb:19:in `to_format'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:153:in `respond'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:146:in `call'
actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:238:in `respond_with'
inherited_resources (1.3.0) lib/inherited_resources/actions.rb:7:in `index'
actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.1.3) lib/active_support/callbacks.rb:416:in `_run__1029254944__process_action__284934475__callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.3) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:75:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:532:in `call'
mongoid (2.4.1) lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
mongoid (2.4.1) lib/mongoid.rb:132:in `unit_of_work'
mongoid (2.4.1) lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.6) lib/rack/etag.rb:23:in `call'
rack (1.3.6) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/flash.rb:247:in `call'
rack (1.3.6) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.6) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/cookies.rb:331:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.3) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.6) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.6) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.6) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.6) lib/rack/lock.rb:15:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.3) lib/rails/engine.rb:456:in `call'
rack (1.3.6) lib/rack/content_length.rb:14:in `call'
railties (3.1.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.6) lib/rack/handler/webrick.rb:59:in `service'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

mongo (1.5.2) lib/mongo/cursor.rb:272:in `>'
mongo (1.5.2) lib/mongo/cursor.rb:272:in `batch_size'
mongo (1.5.2) lib/mongo/cursor.rb:80:in `initialize'
mongo (1.5.2) lib/mongo/collection.rb:236:in `new'
mongo (1.5.2) lib/mongo/collection.rb:236:in `find'
mongoid (2.4.1) lib/mongoid/collections/master.rb:25:in `block in find'
mongoid (2.4.1) lib/mongoid/collections/retry.rb:29:in `retry_on_connection_failure'
mongoid (2.4.1) lib/mongoid/collections/master.rb:24:in `find'
mongoid (2.4.1) lib/mongoid/collection.rb:42:in `find'
mongoid (2.4.1) lib/mongoid/contexts/mongo.rb:174:in `execute'
mongoid (2.4.1) lib/mongoid/contexts/mongo.rb:257:in `iterate'
mongoid (2.4.1) lib/mongoid/criteria.rb:145:in `block in each'
mongoid (2.4.1) lib/mongoid/criteria.rb:145:in `tap'
mongoid (2.4.1) lib/mongoid/criteria.rb:145:in `each'
mongoid (2.4.1) lib/mongoid/criteria.rb:278:in `entries'
mongoid (2.4.1) lib/mongoid/criteria.rb:278:in `as_json'
activesupport (3.1.3) lib/active_support/json/encoding.rb:47:in `block in encode'
activesupport (3.1.3) lib/active_support/json/encoding.rb:78:in `check_for_circular_references'
activesupport (3.1.3) lib/active_support/json/encoding.rb:46:in `encode'
activesupport (3.1.3) lib/active_support/json/encoding.rb:31:in `encode'
activesupport (3.1.3) lib/active_support/core_ext/object/to_json.rb:20:in `to_json'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:95:in `block in '
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:37:in `block in _handle_render_options'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:34:in `each'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:34:in `_handle_render_options'
actionpack (3.1.3) lib/action_controller/metal/renderers.rb:30:in `render_to_body'
actionpack (3.1.3) lib/action_controller/metal/compatibility.rb:43:in `render_to_body'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:99:in `render'
actionpack (3.1.3) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.1.3) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
activesupport (3.1.3) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:252:in `display'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:202:in `api_behavior'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:181:in `rescue in to_format'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:175:in `to_format'
responders (0.6.4) lib/responders/http_cache_responder.rb:19:in `to_format'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:153:in `respond'
actionpack (3.1.3) lib/action_controller/metal/responder.rb:146:in `call'
actionpack (3.1.3) lib/action_controller/metal/mime_responds.rb:238:in `respond_with'
inherited_resources (1.3.0) lib/inherited_resources/actions.rb:7:in `index'
actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.1.3) lib/active_support/callbacks.rb:416:in `_run__1029254944__process_action__284934475__callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.3) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:75:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:532:in `call'
mongoid (2.4.1) lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
mongoid (2.4.1) lib/mongoid.rb:132:in `unit_of_work'
mongoid (2.4.1) lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.6) lib/rack/etag.rb:23:in `call'
rack (1.3.6) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/flash.rb:247:in `call'
rack (1.3.6) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.6) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/cookies.rb:331:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.3) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.6) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.6) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.6) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.6) lib/rack/lock.rb:15:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.3) lib/rails/engine.rb:456:in `call'
rack (1.3.6) lib/rack/content_length.rb:14:in `call'
railties (3.1.3) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.6) lib/rack/handler/webrick.rb:59:in `service'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/01354488679/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

Request

Parameters:

{"limit"=>"2",
"format"=>"json"}
```