The execution of the risk is marked as "too wide", but these are genuine doubts.
Say what I have
@my_model.complex_calculation_resultto display in the view.
What are the pros and cons:
1 - calculating the value on the controller and sending it to the view
Controller:
@result = @my_model.complex_calculation_result # caching the value in the controller
View:
<%= @result %>
2 - Calculating it directly in the view
<%= @my_model.complex_calculation_result %>
I know that the latter alternative represents less code, and I have one smaller instance variable that hangs around.
But are there any differences in performance?
Guess 1 - the view already takes up more memory to display all this, so the calculation may take longer from the inside if it is an expensive memory.
Any light shed on this and comments would be highly appreciated. :)