calling @user.id vs setting id=@user.id

i wouldn't lose any sleep over something like this regarding resource consumption. it really doesn't matter.

even so,

id = user.id

=> 1

user.id.object_id

=> 3

id.object_id

=> 3

They are the same anyway, so why add the extra line of code if it really doesn't do anything?

Personally, @user.id is what i would use. Why? Because if I were reading your code, everywhere you use @user.id, I would know exactly what you meant. Using just 'id' can be a little ambiguous and can lead to possible confusion as to intent. Even if you use 'user_id', see the previous paragraph.

I would be more concerned about resource consumption if you were to have a method which made a complicated calculation, in that case I would use your example.

result_of_complicated_calculation = @obj.complicated_calculation # use result_of_complicated_calculation in the rest of the code

Chris