In development mode:
nil.id
=> "Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id"
In production mode:
nil.id
=> 4
Why?
Look for the line that says the following in your environments configs:
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true # or false in production.rb
This is to prevent you from calling methods on nil
while in development mode. I guess they disabled it for performance reasons in production.
And nil
is a singleton object in ruby, that's why its id
will be 4 no matter what.
Your development.rb evironment has the following line:
config.whiny_nils = true
Which will log an error when you try to call a method on nil
. nil
's id is 4 because it is an object which happens to have an id of 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With