[英]Active Storage in Ruby on Rails 6
我在 Rails 上學習 Ruby,我被 Active Storage 和上傳文件卡住了。 我正在使用本教程:
運行項目時,我在終端中看到一個錯誤: Unpermitted parameter: :header_image
我雙重、三重檢查了我的代碼,在一個絕望的舉動中,我什至通過chmod -R 777更改了整個項目目錄中的權限,但無法消除此錯誤 go 。
我通過 A2hosting.com 和 Ubuntu 20.04 在遠程非托管服務器上運行項目
有任何想法嗎? 先感謝您!
如有疑問,請參閱官方文檔,它非常清楚並且有代碼示例https://edgeguides.rubyonrails.org/active_storage_overview.html在 Z20F35E630DAF44DBFA4C3F6 你有定義8F
has_one_attached :header_image
提交表格后附上文件
post.header_image.attach(params[:header_image])
controller 具有相同方法的 2 個定義,並且只會采用 2 種可能性中的一種添加從教程中編輯的以下內容
# /app/controllers/posts_controller.rb
def post_params
params.require(:post).permit(:title, :body, files: [], :header_image)
end
header_images 必須添加到允許的參數列表中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.