I have a Portfolio scaffold. From the update method of the controller, I am calling the show view. However, a variable (@weights) that I am instantiating in the controller does not preserve its value.
Controller:
@weights = @portfolio.compute_weights
pp "in the controller, the weights are #{@weights}"
format.html { redirect_to @portfolio, notice: 'Portfolio was successfully updated.' }
format.json { render :show, status: :ok, location: @portfolio }
View
<% pp "in the view, the weights are #{@weights}"%>
The output is
"in the controller, the weights are {\"Bitcoin\"=>1.0, \"Litecoin\"=>0.0}"
"in the view, the weights are "
Why is this happening?
<%= debug @weights%>and let me know what you are getting