我在我的rails应用程序中使用AuthLogic gem。它在开发环境中工作正常但是当我切换到生产环境时,我收到一个错误,导致应用无法启动:
/home/.../rails/xxx/app/models/book.rb:2: undefined local variable or method `acts_as_authentic' for Book:Class (NameError)
from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:158:in `require'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:265:in `require_or_load'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:224:in `depend_on'
from /home/.../ruby/gems/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:136:in `require_dependency'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:414:in `load_application_classes'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:413:in `each'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:413:in `load_application_classes'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:411:in `each'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:411:in `load_application_classes'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:197:in `process'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:113:in `send'
from /home/.../ruby/gems/gems/rails-2.3.8/lib/initializer.rb:113:in `run'
from ./public/../config/environment.rb:28
from ./public/dispatch.fcgi:21:in `require'
from ./public/dispatch.fcgi:21
我正在使用authlogic(2.1.5)和rails(2.3.8)
错误只发生在生产环境中,即使我的生产和dev DB是相同的。 localhost与Web服务器上的问题相同。我真的很感激我能得到的任何帮助。如果需要更多信息,请告诉我。非常感谢!
9月15日编辑: 谢谢你的回复。它被冻结在我的应用程序中。我不确定如何验证它是否以我运行我的Web服务器的用户可用的方式安装。这是rake gems的输出RAILS_ENV = production:
rake gems RAILS_ENV=production
(in /Users/my_user_name/Sites/my_app_name)
- [F] authlogic
- [R] activesupport
- [F] acts-as-taggable-on = 2.0.0.rc1
- [R] rails
- [F] will_paginate
- [I] nokogiri
I = Installed
F = Frozen
R = Framework (loaded before rails starts)
9月17日编辑: 我尝试解冻宝石并得到同样的错误。
答案 0 :(得分:0)
authlogic gem是在您的生产环境中安装还是冻结在您的应用程序中?此外,它是否以您运行Web服务器的用户可用的方式安装? (如果您已经检查了这一点,请道歉,但从一开始就有意义)
最后,值得检查一下,环境.rb中的config.gem "authlogic"
调用是否在使用Book
类之前,这似乎是导致问题的原因。