Ruby on rails 获取rails错误没有与[GET]匹配的路由/用户/登录;

Ruby on rails 获取rails错误没有与[GET]匹配的路由/用户/登录;,ruby-on-rails,devise,apartment-gem,Ruby On Rails,Devise,Apartment Gem,我正在尝试建立一个多租户应用程序,我在这里有这个问题,我无法弄清楚是怎么回事。我一直在犯这个错误。这是我的路线。我错过了什么 class SubdomainPresent def self.matches?(request) request.subdomain.present? end end class SubdomainBlank def self.matches?(request) request.subdomain.blank? end end Rai

我正在尝试建立一个多租户应用程序,我在这里有这个问题,我无法弄清楚是怎么回事。我一直在犯这个错误。这是我的路线。我错过了什么

class SubdomainPresent
  def self.matches?(request)
    request.subdomain.present?
  end
end

class SubdomainBlank
  def self.matches?(request)
    request.subdomain.blank?
  end
end

Rails.application.routes.draw do
  resources :contacts
  constraints(SubdomainPresent) do
    root 'contacts#index', as: :subdomain_root
    devise_for :users
    resources :users, only: :index
  end

  constraints(SubdomainBlank) do
    root "welcome#index"
    resources :accounts, only: [:new, :create]
  end
end
这是我的耙子路线

                  Prefix Verb   URI Pattern                    Controller#Action
                contacts GET    /contacts(.:format)            contacts#index
                         POST   /contacts(.:format)            contacts#create
             new_contact GET    /contacts/new(.:format)        contacts#new
            edit_contact GET    /contacts/:id/edit(.:format)   contacts#edit
                 contact GET    /contacts/:id(.:format)        contacts#show
                         PATCH  /contacts/:id(.:format)        contacts#update
                         PUT    /contacts/:id(.:format)        contacts#update
                         DELETE /contacts/:id(.:format)        contacts#destroy
          subdomain_root GET    /                              contacts#index
        new_user_session GET    /users/sign_in(.:format)       devise/sessions#new
            user_session POST   /users/sign_in(.:format)       devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)      devise/sessions#destroy
       new_user_password GET    /users/password/new(.:format)  devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format) devise/passwords#edit
           user_password PATCH  /users/password(.:format)      devise/passwords#update
                         PUT    /users/password(.:format)      devise/passwords#update
                         POST   /users/password(.:format)      devise/passwords#create
cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
   new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
       user_registration PATCH  /users(.:format)               devise/registrations#update
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
                         POST   /users(.:format)               devise/registrations#create
                   users GET    /users(.:format)               users#index
                    root GET    /                              welcome#index
                accounts POST   /accounts(.:format)            accounts#create
             new_account GET    /accounts/new(.:format)        accounts#new
这是导致错误的填写表单:

designe/sessions/new.html.erb

<h2>Log in</h2>

<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
  <div class="form-inputs">
    <%= f.input :email, required: false, autofocus: true %>
    <%= f.input :password, required: false %>
    <%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
  </div>

  <div class="form-actions">
    <%= f.button :submit, "Log in" %>
  </div>
<% end %>

<%= render "devise/shared/links" %>
登录

这里还有accounts_controller.rb

class AccountsController < ApplicationController
   skip_before_filter :authenticate_user!, only: [:new, :create]
    def new
      @account = Account.new
      @account.build_owner
    end

    def create
      @account = Account.new(account_params)
     if @account.valid?
       Apartment::Database.create(@account.subdomain)
       Apartment::Database.switch(@account.subdomain)
       @account.save
       redirect_to new_user_session_url(subdomain: @account.subdomain)
      else
        render action: 'new'
      end
   end

 private
   def account_params
     params.require(:account).permit(:subdomain, owner_attributes: [:name, :email, :password, :password_confirmation])
   end
 end
class AccountsController
您的约束是否成功?例如,您是否使用子域登录?如果我键入子域,则可以正常工作。但是主页没有子域。用户继续用子域创建一个帐户,当它被提交时,就是我收到错误的时候。似乎有某种重定向错误,我猜,但真的不知道…非常愚蠢的一个:你每次更改路由时都会重新启动服务器。rb?Routes.rb仅在服务器启动时被解释一次。此外,我在您发布的代码中没有看到方法
new
。Rails正在
designe/sessions
中寻找方法
new
,是的,每次进行更改时都会重新启动服务器。我在designe/sessions中添加了new.html.erb,并将其添加到我的主要帖子中