簡體   English   中英

更新后找不到模板

[英]No template found after Update

又是我。 昨天解決了我的兩個問題之后,讓我們再嘗試一個。 這次我在Ruby on Rails的更新功能上遇到了一些問題。

因此,原則上更新效果良好。 它保存了新數據,一切正常,請期待一件事:當我單擊“保存”按鈕時,前端沒有任何反應。 如我所說,數據已正確更新,但我認為應該redirectredirectroot_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)

提前致謝!

這對我有用,並且希望將它保存在數據庫中也必須對您有用。 代替“ Flash”,使用“ Alert”。 我已經根據您的代碼更改了代碼。

def update
 @resume = Resume.find(params[:id])
 if @resume.update(profile_params)
   redirect_to root_path, alert: "Your resume is saved!"
 else
   render 'edit', alert: "Oops! There was a problem, please try again"
 end
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM