У меня есть Portfolio
scaffold
. Из метода update
из controller
я звоню view
. Однако переменная (@weights
), которую я создаю в controller
, не сохраняет ее значение.Rails - переменная экземпляра не сохраняет значение
Контроллер:
@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 }
Просмотр
<% pp "in the view, the weights are #{@weights}"%>
Выход
"in the controller, the weights are {\"Bitcoin\"=>1.0, \"Litecoin\"=>0.0}"
"in the view, the weights are "
Почему это происходит?
Поместите это в свой файл просмотра '<% = debug @ weightights%>' и дайте мне знать, что вы получаете – rick