Ruby on rails 为API设计路线

Ruby on rails 为API设计路线,ruby-on-rails,ruby,json,rspec,devise,Ruby On Rails,Ruby,Json,Rspec,Devise,我如何理解以下错误消息(测试时)以及为什么在向我的注册控制器创建操作发出post请求时,我使用的是/lnf.json 在我的路线中,我有以下约束和路径设置 constraints(subdomain: 'api') do devise_for :users, path: 'lnf', controllers: { registrations: "registrations" } end 还有我的注册管理员 class RegistrationsController < Devise:

我如何理解以下错误消息(测试时)以及为什么在向我的注册控制器创建操作发出post请求时,我使用的是
/lnf.json

在我的路线中,我有以下约束和路径设置

constraints(subdomain: 'api') do
  devise_for :users, path: 'lnf', controllers: { registrations: "registrations" }
end
还有我的注册管理员

class RegistrationsController < Devise::RegistrationsController
  skip_before_action :verify_authenticity_token
  respond_to :json

  def create
   super
  end

end
但我在运行测试时出错

AbstractController::ActionNotFound:
Could not find devise mapping for path "/lnf.json?
编辑 根据请求输出Rake路由

 new_user_session GET    /lnf/sign_in(.:format)          devise/sessions#new {:subdomain=>"api"}
        user_session POST   /lnf/sign_in(.:format)          devise/sessions#create {:subdomain=>"api"}
destroy_user_session DELETE /lnf/sign_out(.:format)         devise/sessions#destroy {:subdomain=>"api"}
       user_password POST   /lnf/password(.:format)         devise/passwords#create {:subdomain=>"api"}
   new_user_password GET    /lnf/password/new(.:format)     devise/passwords#new {:subdomain=>"api"}
  edit_user_password GET    /lnf/password/edit(.:format)    devise/passwords#edit {:subdomain=>"api"}
                     PATCH  /lnf/password(.:format)         devise/passwords#update {:subdomain=>"api"}
                     PUT    /lnf/password(.:format)         devise/passwords#update {:subdomain=>"api"}
   user_confirmation POST   /lnf/confirmation(.:format)     devise/confirmations#create {:subdomain=>"api"}
 new_user_confirmation GET    /lnf/confirmation/new(.:format) devise/confirmations#new {:subdomain=>"api"}
注册管理员

 cancel_user_registration GET    /lnf/cancel(.:format)           registrations#cancel {:subdomain=>"api"}
   user_registration POST   /lnf(.:format)                  registrations#create {:subdomain=>"api"}
  new_user_registration GET    /lnf/sign_up(.:format)          registrations#new {:subdomain=>"api"}
 edit_user_registration GET    /lnf/edit(.:format)             registrations#edit {:subdomain=>"api"}
                     PATCH  /lnf(.:format)                  registrations#update {:subdomain=>"api"}
                     PUT    /lnf(.:format)                  registrations#update {:subdomain=>"api"}
                     DELETE /lnf(.:format)                  registrations#destroy {:subdomain=>"api"}
                 lnf POST   /lnf(.:format)                  registrations#create {:subdomain=>"api", :format=>"json"}

看起来design#u for routes部分需要稍微调整一下(或者使用lnf aka“post'/lnf”为您的案例添加特殊路由到:'registrations#create',默认值:{format:'json'})。
请您将“rake routes | grep designe”命令的输出放在这里好吗?

谢谢,我已经更新了注册路径#create,您想要所有的路径吗?有了这个特殊的路径,我如何覆盖我当前设置提供的路径?您可以,请向我展示
rake routes | grep designe
的输出,您是否尝试在测试参数中使用:subdomain=>“api”?post:create,subdomain:api,format::json,:user=>{user params here}我想你可以从这个讨论中得到一些想法是的,我试过,
subdomain::api
subdomain:'api'
 cancel_user_registration GET    /lnf/cancel(.:format)           registrations#cancel {:subdomain=>"api"}
   user_registration POST   /lnf(.:format)                  registrations#create {:subdomain=>"api"}
  new_user_registration GET    /lnf/sign_up(.:format)          registrations#new {:subdomain=>"api"}
 edit_user_registration GET    /lnf/edit(.:format)             registrations#edit {:subdomain=>"api"}
                     PATCH  /lnf(.:format)                  registrations#update {:subdomain=>"api"}
                     PUT    /lnf(.:format)                  registrations#update {:subdomain=>"api"}
                     DELETE /lnf(.:format)                  registrations#destroy {:subdomain=>"api"}
                 lnf POST   /lnf(.:format)                  registrations#create {:subdomain=>"api", :format=>"json"}