NoMethodError in Devise::RegistrationsController#edit 用Devise套件作為系統的帳號管理功能,結果在這個檔案出現錯誤. app/controller/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 ? protected def configure_permitted_parameters devise_parameter_sanitizer . for ( :sign_up ) { | u | u.permit( :username , :email , :password , :password_confirmation , :remember_me , :avatar , :avatar_cache ) } devise_parameter_sanitizer . for ( :account_update ) { | u | u.permit( :username , :password , :password_confirmation , :current_password , :avatar ) } end end 只要將for修正成permit,就可以了. def configure_permitted_parameters devise_parameter_sanitizer .permit ( :sign_up ) {... } devise_parameter_sanitizer .permit ( :account_update ) {... } end