mercredi 21 décembre 2016

BSON::InvalidObjectId illegal ObjectId format Rails 3.1.1

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.

Aucun commentaire:

Enregistrer un commentaire