Problems with Object#id deprecation

Hello everyone, in a test helper in my app I call category.id that gets the id of category in the database. However, when running RSpec I get the following error:

As a parla customer

/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning: Object#id will be deprecated; use Object#object_id

/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning: Object#id will be deprecated; use Object#object_id

/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning: Object#id will be deprecated; use Object#object_id

/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning: Object#id will be deprecated; use Object#object_id

/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning: Object#id will be deprecated; use Object#object_id

/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning: Object#id will be deprecated; use Object#object_id

I can’t change id method to object_id because they’re totally different things. One is the actual id of the model instance, other is the object_id Ruby gives to any of its objects.

Does anyone know the solution for this problem?

I appreciate your attention and help!

Hello everyone, in a test helper in my app I call category.id that gets the
id of category in the database. However, when running RSpec I get the
following error:

As a parla customer
/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning:
Object#id will be deprecated; use Object#object_id
/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning:
Object#id will be deprecated; use Object#object_id
/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning:
Object#id will be deprecated; use Object#object_id
/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning:
Object#id will be deprecated; use Object#object_id
/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning:
Object#id will be deprecated; use Object#object_id
/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning:
Object#id will be deprecated; use Object#object_id

I can't change id method to object_id because they're totally different
things. One is the actual id of the model instance, other is the object_idRuby gives to any of its objects.
Does anyone know the solution for this problem?

This can happen because the object you're calling id on isn't what you
think it is (eg it's nil)

Fred

It would be worth posting the spec code too. In addition to Fred's
suggestion, I'd wonder whether you might have accidentally used
Model.id rather than model.id somewhere...

Oh yes, actually, this code isn’t a actual spec, it is a file in spec/acceptance/support/paths.rb, there is the code:

module NavigationHelpers

# Put helper methods related to the paths in your application here.

def homepage

"/"

end

def start_order_page

"/categories"

end

def products_page category

"/categories/#{category.id}/products"

end

def new_pizza_page

"/pizzas/new"

end

end

RSpec.configuration.include NavigationHelpers, :type => :acceptance

please tell me what's wrong with this,

Thanks!

I would be most suspicious of the products_page method... as Fred
said, the "category" is likely to be nil.
Can you debug at that point?

I’ll try, in the meantime… won’t this method be deprecated, what’s the appropriate one now?

Or maybe I am missing something?

Thanks!

Isn't it supposed to be #instance_id now?

Walter

Oops, problem fixed. Turns out it was what Frederick and pavling pointed out: was calling nil.

Thanks everyone, for the responses. And I’ll keep instance_id in mind too, thanks, Walter!

Quoting Rodrigo Alves Vieira <rodrigo3n@gmail.com>:

Hello everyone, in a test helper in my app I call category.id that gets the
id of category in the database. However, when running RSpec I get the
following error:

  As a parla customer
/Users/saulolopes/code/parla/spec/acceptance/support/paths.rb:13: warning:
Object#id will be deprecated; use Object#object_id

I use category[:id] instead and it always works as expected. Clumsy, a kludge,
but it works.

HTH,
  Jeffrey