deviseを使っている時の画像アップロード手順


views/devise/registrations/new.html.erb

にこれを追加
editにも追加する。

new.html.erb

   <div class="field">
    <%= f.label :image %><br />
    <%= f.file_field :image %>
  </div>

edit.html.erb

   <div class="field">
    <%= f.label :image %><br />
    <%= f.file_field :image %>
  </div>

アプリケーションコントローラーにストロングパラメーターを追加
controllers/application_controller.rb

devise_parameter_sanitizer.for(:sign_up)<< [:name, :phone_number, :image]

:imageを追加。

application_controller.rb

 class ApplicationController < ActionController::Base
  # Prevent CSRF attacks by raising an exception.
  # For APIs, you may want to use :null_session instead.
  protect_from_forgery with: :exception
before_action :configure_permitted_parameters, if: :devise_controller?


  private

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up)<< [:name, :phone_number, :image]
    devise_parameter_sanitizer.for(:sign_in)<< [:name, :phone_number]

  end


end