Ruby on rails 3.1 使用Rails 3.1.0设计经过身份验证的块问题

Ruby on rails 3.1 使用Rails 3.1.0设计经过身份验证的块问题,ruby-on-rails-3.1,devise,Ruby On Rails 3.1,Devise,我正在使用mongoid、Rails 3.1.0和Desive 1.5.3 在my routes.rb中,我有一个经过身份验证的块 authenticated :user do get "dashboard" => ":controller#:action", constraints: lambda { |r| not r.env['warden'].user(:user).primary_account.nil? } root to: ":controller#:action",

我正在使用mongoid、Rails 3.1.0和Desive 1.5.3

在my routes.rb中,我有一个经过身份验证的块

authenticated :user do
  get "dashboard" => ":controller#:action", constraints: lambda { |r| not r.env['warden'].user(:user).primary_account.nil? }
  root to: ":controller#:action", constraints: lambda { |r| not r.env['warden'].user(:user).primary_account.nil? }

end
加载应用程序后,即使用户未通过Desive进行身份验证,应用程序也会在块内进行。这会导致用户对象部分出错,因为加载时它仍然为零。有什么建议吗