Ruby on rails 设计-仅在多次尝试后登录-子域和PG

Ruby on rails 设计-仅在多次尝试后登录-子域和PG,ruby-on-rails,ruby-on-rails-3,postgresql,devise,subdomain,Ruby On Rails,Ruby On Rails 3,Postgresql,Devise,Subdomain,我正在使用rails3.2和design3.0 我使用子域和PG的多个模式将一个帐户与另一个帐户隔离 我的系统上的用户只有在多次尝试后才能登录。日志里什么都没有,我完全不懂。我希望有人能给我指出正确的方向 我的代码如下: 应用程序控制器- before_filter :setup_schema def setup_schema if request.subdomain.blank? || request.subdomain == 'www' redirect_to "http://

我正在使用
rails3.2
design3.0

我使用子域和PG的多个模式将一个帐户与另一个帐户隔离

我的系统上的用户只有在多次尝试后才能登录。日志里什么都没有,我完全不懂。我希望有人能给我指出正确的方向

我的代码如下:

应用程序控制器-

before_filter :setup_schema

def setup_schema
  if request.subdomain.blank? || request.subdomain == 'www'
    redirect_to "http://www.#{ENV['DOMAIN']}.com"
  else
    @tenant = Account.find_by_name(request.subdomain)
    if @tenant.nil?
      redirect_to "http://www.#{ENV['DOMAIN']}.com"
    else
      ActiveRecord::Base.connection.schema_search_path = "#{@tenant.schema},hstore"
      Delayed::Job.table_name = 'public.delayed_jobs'
    end
  end
end
会话存储-

XXX::Application.config.session_store :cookie_store, key: '_XXX_session', domain: :all
路线:

 devise_for :users, controllers: {registrations: "registrations"}, path_names: { sign_in: "login", sign_out: "logout"} 
as :user do
    get 'users/edit' => 'devise/registrations#edit', as: 'edit_user_registration'
    get 'users/edit_password' => 'devise/registrations#edit_password', as: 'edit_pass_user_registration'
    post "user_create" => "users#create",  as: 'user_create'
end

resources :dashboards, only: [:index]

devise_scope :user do
  constraints(Subdomain) do
    authenticated :user do
      root to: 'dashboards#index'
    end
    unauthenticated :user do
      root to: 'sessions#new'
    end
    root to: 'dashboards#index'
  end
end
我面临的另一个问题是-

假设我登录了1个子域,我在根路径,即,
subdomain1.XXX.com
,然后我与另一个用户在另一个浏览器的另一个子域中登录,现在当我来到我的第一个子域时,我就注销了。 然而,如果我是一个其他url,例如,
subdomain1.XXX.com/projects
,然后我在另一个浏览器的另一个子域中与另一个用户登录,现在当我来到我的第一个子域时,我不会被注销

你能告诉我我错过了什么吗? 我遗漏了一些关键的概念,或者这必须与设计有关

编辑以添加日志-

Started POST "/users/login" 
Completed 302 Found in 197.2ms (ActiveRecord: 0.0ms)
Processing by SessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"F/QNpMOAxEHK1Y/M9n1vyyqqPvO0859XNqd4ylrI+G0=", "user"=>{"login"=>"login1", "password"=>"[FILTERED]"}, "commit"=>"Entrar"}
Redirected to http://subdomain2.XXX.com/

heroku[router]: at=info method=POST path="/users/login"     host=subdomain2.XXX.com 
Started GET "/" 
Rendered devise/shared/_links.html.haml (1.4ms)
Rendered layouts/_messages.html.haml (0.1ms)

Processing by SessionsController#new as HTML
Rendered devise/sessions/new.html.haml within layouts/login (10.7ms)

heroku[路由器]:at=info method=GET path=“/”host=subdomain2.XXX.com

日志中必须有一些内容,因此如果您可以包含登录尝试失败与成功的日志,那就太好了。至于您的第二个问题:您在子域之间共享Rails中的一个会话,因此当您登录到另一个帐户时,第一个会话自然会失效。您可能应该将会话cookie的作用域设置到子域。@MichalSzyndel我已经编辑了问题以添加日志