我在 Rails 3.0.9 应用程序中使用默认设置的事件管理。即,我有 User
模型,并为客户登录设计身份验证,并且事件管理在 AdminUser< 上运行
模型。除了事件的管理员登录页面之外,一切正常。当我尝试访问http://localhost:3000/admin时我很快就得到了活跃的管理员登录页面。但在我正确/错误输入用户名/密码后,身份验证过程需要近 3-5 分钟。由于这个原因,我什至无法在heroku上部署应用程序,并且在heroku日志上收到超时错误。
但是在开发模式下,当我登录到事件管理后,一切都运行良好。我假设这是由于路由问题而发生的。所以我将我的路线文件完整地粘贴到这里。
有人可以帮我解决这个问题吗?谢谢
1月9日更新:看来这个问题与我认为的路线无关。我删除了所有其他模型/ Controller / View /路由,只留下 User
和 AdminUser
内容。但我仍然感受到缓慢。
最佳答案
没关系,我已经找到了问题,也可能找到了解决方案。我将其发布在这里,以便它可以帮助其他遇到类似问题的人。
在我的应用程序中,我最初使用 authlogic
gem 进行身份验证,但最近我已将其切换为 devise
以获得更好的支持。但我仍然希望允许老用户使用相同的密码登录该应用程序。因此,我将设备加密从 Bcrypt 覆盖为 Authlogic 的 sha512,如下所示。
config/initializers/devise.rb
config.encryptor = :authlogic_sha512
但我从未更改 AdminUser
模型以适应上述更改。
所以修复应该在我的模型中,我应该使用 :encryptable
和 :encryptor => :authlogic_sha512
class AdminUser < ActiveRecord::Base
devise :database_authenticatable,
:recoverable, :rememberable, :trackable, :validatable,:encryptable, `:encryptor => :authlogic_sha512`
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
end
并且在 AdminUser 迁移文件中应启用可加密列
create_table(:admin_users) do |t|
t.database_authenticatable :null => false
t.recoverable
t.rememberable
t.trackable
t.encryptable
# t.confirmable
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
# t.token_authenticatable
t.timestamps
end
关于ruby-on-rails-3 - 事件管理员登录速度慢,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8736093/