Rails: 未定义的方法“abc_users_path”

Rails: undefined method `abc_users_path'

我正在尝试使用用户控制器中的方法 (abc) 远程更新设计用户记录的某些属性。

路线

    devise_for :users, controllers: { confirmations: "users/confirmations", omniauth_callbacks: "users/omniauth_callbacks" }

    resources :users, only: [:index, :show, :abc] do
        get "/abc" => "users#abc"
    end

用户控制器

def abc
    user = user.find(params[:id])
    params[:abc].each do |key, value|
        user.key = value
    end
    user.save!
    respond_to do |format|
        format.html { redirect_back(fallback_location: root_path) }
        format.js # render users/abc.js.erb
    end
end

查看

= link_to(abc_users_path(current_user, abc: true), remote: true) do
    ABC

抛出的错误:

NoMethodError in Controller#method
undefined method `abc_users_path' for #<#:0xc2ee630>

我很欣赏每一个答案!

你想要的是user_abc_path,你可以在控制台路由运行rails routes中验证。