继续获得 'undefined method error' user_url

Keep getting 'undefined method error' user_url

我在应用程序中使用 devise,但我不断收到未定义方法错误 user_url。这是我所拥有的,请帮我解决这个问题

这是错误:

NoMethodError in Users::SessionsController#create
undefined method `user_url' for #<Users::SessionsController:0xa33291c>

Rails.root: /home/vagrant/code/AppSample

Application Trace | Framework Trace | Full Trace
actionpack (4.0.10) lib/action_dispatch/routing/polymorphic_routes.rb:129:in `polymorphic_url'
actionpack (4.0.10) lib/action_dispatch/routing/url_for.rb:159:in `url_for'
actionpack (4.0.10) lib/action_controller/metal/redirecting.rb:101:in `_compute_redirect_to_location'
...

这是用户 session_controller:

class Users::SessionsController <
Devise::SessionsController

  def after_sign_in_path_for(resource)
    @tenants_dashboard_path
  end


  def create
    user = User.find_by(:email => params[:email])
    manager = Manager.find_by(:email => (params[:email])
    if user && tenant.authenticate (params[:password])
      session[:tenant_id] = tenant.id
      redirect_to users_main_url, notice: "You are Logged in!"
    elsif
    manager && manager.authenticate(params[:password])
      session[:manager_id] = manager.id
      return managers_main_url, notice: "You are Logged in!"
    else
      flash.now.alert = "Email or password is invalid."
    end
end

错误是在我尝试将我的用户重定向到仪表板页面时出现的。这是我的应用程序控制器中的登录方法

 def after_sign_in_path_for(resource)
    if resource.is_a?(Users)
      return users_dashboard_path, notice: "You are Logged in!"
    elsif resource.is_a?(Managers)
      return managers_dashboard_path, notice: "You are Logged in!"
    end
  end

这是路线:

    devise_for :users, controllers: {registrations: "users/registrations", sessions: "users/sessions" }
    devise_for :managers, controllers: {registrations: "managers/registrations", sessions: "managers/sessions" }
    resources :reports
    resource :dashboard

  get "/managers/why_use_us" => "managers/landing#index", as: :managers_why
  get "/users/why_choose_us" => "users/landing#index", as: :tenants_why

  get "/managers/LeaseDefend_dashboard" => "managers/dashboard#index", as: :managers_main
  get "/users/LeaseDefend_dashboard" => "users/dashboard#index", as: :tenants_main

  namespace :users do
    get 'landing', to: 'landing#index'
    get 'dashboard', to: 'dashboard#index'
    resources :landing, :dashboard
  end''

我不知道要更改什么我更改了资源以匹配用户文件夹的名称,即经理和租户

我更改了 after_sign_in_path 方法并在每个控制器中放置了一个单独的方法,因为有不同的用户