TypeError at / no implicit conversion from nil to integer

rand_id = rand([email protected]) @abc =
@abc.hits[rand_id].primary_key.to_i

i am getting an no implicit conversion from nil to integer .please
suggest any solution

error is coming from the C code inside the Ruby interpreter. A core
class, implemented in C, is being handed a nil when it expects an
Integer. It may have a #to_i but it doesn’t have a #to_int and so the
result is the TypeError.

but how can i change there please suggest solution…

what’s @abc?