11. 実際にコードを書いてみる(実装3)
?
ControllerとViewに画像のアップロード部分の処理を書く
② app/controllers/newinfos_controller.rbに追記
# Never trust parameters from the scary internet, only allow the white list through.
def newinfo_params
params.require(:newinfo).permit(:title, :detail, :published, :?ag, :image)
end
end
:imageを追記してあげる
ここまでで画面から画像をアップロードする処理を書きました。
画面で実際のDemo
③ app/views/newinfos/_form.html.rbに追記
<div class="?eld">
<%= f.label :image %><br>
<%= f.?le_?eld :image %>
</div>
画像アップロード用のinputタグを出力する