I'm getting the following error when trying to use the delete method in a Ruby on Rails application.
BSON::InvalidObjectId in ServicesController#destroy
I'm using Rails 3.1.1 and MongoDB v2.4.15
Below is the Delete
link in question.
%li= link_to 'Delete', @service, :method => :delete, :confirm => "Are you sure you want to delete this service?"
Here is the log error:
Started DELETE "/services/appeals" for 127.0.0.1 at 2016-12-21 11:08:42 -0500
Creating scope :orderable_scope. Overwriting existing method Service.orderable_scope.
Processing by ServicesController#destroy as HTML
Parameters: {"authenticity_token"=>"xxx", "id"=>"appeals"}
Completed 500 Internal Server Error in 11ms
BSON::InvalidObjectId (illegal ObjectId format: appeals):
When deleting items in other collections it works fine. I'm able to use the "services" edit link without errors. Below is the working Delete
link and logs for deleting an attorney.
Working Link %li= link_to "Delete", @attorney, :method => :delete, :confirm => "Are you sure you want to delete this attorney?"
Working Log
Started DELETE "/attorneys/first-last" for 127.0.0.1 at 2016-12-21 10:37:07 -0500
Creating scope :orderable_scope. Overwriting existing method Attorney.orderable_scope.Processing by AttorneysController#destroy as HTMLParameters: {"authenticity_token"=>"xxx", "id"=>"first-last"}
MONGODB x_development['system.namespaces'].find({})
MONGODB x_development['attorneys'].find({:slug=>"first-last"}).limit(-1).sort([[:_id, :asc]])
MONGODB x_development['system.namespaces'].find({})
MONGODB x_development['users'].find({:_id=>BSON::ObjectId('585a9dbc737da97cbd000006')}).limit(-1).sort([[:_id, :asc]])
Creating scope :orderable_scope. Overwriting existing method Service.orderable_scope.
MONGODB x_development['system.namespaces'].find({})
Redirected to http://ift.tt/2hHOsSB
Completed 302 Found in 69ms`
It's another developers application that I'm trying to get working correctly again. I'm not very experienced with Ruby, Rails, or MongoDB.
UPDATE Below is the Full Trace
bson (1.4.0) lib/bson/types/object_id.rb:126:in `from_string'
mongoid (2.4.12) lib/mongoid/fields/internal/object_id.rb:38:in `serialize'
mongoid (2.4.12) lib/mongoid/criterion/optional.rb:97:in `for_ids'
mongoid (2.4.12) lib/mongoid/criteria.rb:310:in `search'
mongoid (2.4.12) lib/mongoid/criterion/inclusion.rb:125:in `find'
mongoid (2.4.12) lib/mongoid/finders.rb:84:in `find'
inherited_resources (1.3.1) lib/inherited_resources/base_helpers.rb:44:in `resource'
cancan (1.6.7) lib/cancan/inherited_resource.rb:11:in `load_resource_instance'
cancan (1.6.7) lib/cancan/controller_resource.rb:32:in `load_resource'
cancan (1.6.7) lib/cancan/controller_resource.rb:25:in `load_and_authorize_resource'
cancan (1.6.7) lib/cancan/controller_resource.rb:10:in `block in add_before_filter'
activesupport (3.1.1) lib/active_support/callbacks.rb:439:in `_run__3707406960644643515__process_action__1333295842175195574__callbacks'
activesupport (3.1.1) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.1) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.1) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.1) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.1) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
actionpack (3.1.1) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.1) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.1) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.1) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.1) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.1) 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:131: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.1) lib/action_dispatch/routing/route_set.rb:532:in `call'
mongoid (2.4.12) lib/rack/mongoid/middleware/identity_map.rb:33:in `block in call'
mongoid (2.4.12) lib/mongoid.rb:133:in `unit_of_work'
mongoid (2.4.12) lib/rack/mongoid/middleware/identity_map.rb:33:in `call'
actionpack (3.1.1) 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:35:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/flash.rb:243: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.1) lib/action_dispatch/middleware/cookies.rb:331:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.1) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.1) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.1) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.6) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.1) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.1) 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.1) 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.1) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.1) lib/rails/engine.rb:456:in `call'
railties (3.1.1) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.6) lib/rack/handler/webrick.rb:59:in `service'
/Users/Home/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/Users/Home/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/Users/Home/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
Anyone have any ideas? Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire