i wouldn't lose any sleep over something like this regarding resource
consumption. it really doesn't matter.
id = user.id
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