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_idRuby gives to any of its objects.
Does anyone know the solution for this problem?

I appreciate your attention and help!

On Mar 15, 7:40pm, Rodrigo Alves V. [email protected] wrote:

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

On 15 March 2011 19:40, Rodrigo Alves V. [email protected]
wrote:

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:

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…

On 16 March 2011 00:21, Rodrigo Alves V. [email protected]
wrote:

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
def products_page category
“/categories/#{category.id}/products”
end

please tell me what’s wrong with this,

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?

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’ll try, in the meantime… won’t this method be deprecated, what’s the
appropriate one now?

Or maybe I am missing something?

Thanks!

On Mar 16, 2011, at 1:58 PM, Rodrigo Alves V. wrote:

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 V. [email protected]:

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