1
重新找回它。在我的兩個問題昨天解決後,讓我們嘗試另一個問題。這一次我遇到了Ruby on Rails的更新功能問題。更新後找不到模板
所以,主要是更新是做得很好。它保存了新的數據,一切都很好,期待一件事:當我點擊「保存」按鈕時,前端沒有任何反應。正如我所說,數據更新正確,但在我看來,它應該我redirect
到root_path
,因爲有重定向。願你能告訴我我做錯了什麼嗎?我嘗試了其他重定向/渲染的幾件事,但沒有奏效。
這段代碼是我的控制器的一部分:
def update
@resume = Resume.find(params[:id])
if @resume.update_attributes(resume_params)
flash[:success] = 'The file has been updated!'
redirect_to root_path
else
render 'edit'
end
end
這是我在日誌中得到了錯誤:事先
No template found for ResumesController#update, rendering head :no_content
Completed 204 No Content in 96ms (ActiveRecord: 21.1ms)
謝謝!
哪裏的前端代碼?編輯頁面? – lcguida
你有'app/views/resumes/edit.html.erb'視圖嗎? – max
你應該使用'update'而不是'update_attributes'。後者只是'update'的別名,因爲兼容性原因,它仍然存在。 – max