我有一个在本地系统上成功构建的应用程序,但是当部署到 Heroku 或运行时rails server -e production
产生:
=> Rails 4.0.0 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/home/nmradar/Documents/old-manager/app/controllers/registrations_controller.rb:2:in `<top (required)>': uninitialized constant Users (NameError)
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:465:in `block (2 levels) in eager_load!'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:464:in `each'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:464:in `block in eager_load!'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:462:in `each'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:462:in `eager_load!'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:347:in `eager_load!'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `each'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `instance_exec'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:30:in `run'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:55:in `block in run_initializers'
from /home/nmradar/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:150:in `block in tsort_each'
from /home/nmradar/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:183:in `block (2 levels) in each_strongly_connected_component'
from /home/nmradar/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:219:in `each_strongly_connected_component_from'
from /home/nmradar/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:182:in `block in each_strongly_connected_component'
from /home/nmradar/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each'
from /home/nmradar/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:180:in `each_strongly_connected_component'
from /home/nmradar/.rvm/rubies/ruby-2.0.0-p247/lib/ruby/2.0.0/tsort.rb:148:in `tsort_each'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/initializable.rb:54:in `run_initializers'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/application.rb:215:in `initialize!'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/nmradar/Documents/old-manager/config/environment.rb:5:in `<top (required)>'
from /home/nmradar/Documents/old-manager/config.ru:3:in `block in <main>'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /home/nmradar/Documents/old-manager/config.ru:in `new'
from /home/nmradar/Documents/old-manager/config.ru:in `<main>'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:49:in `new_from_string'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/builder.rb:40:in `parse_file'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands/server.rb:48:in `app'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands/server.rb:75:in `start'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:78:in `block in <top (required)>'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `tap'
from /home/nmradar/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/commands.rb:73:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
我的 environment.rb 是
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
OldManager::Application.initialize!
而registrations_controller.rb是
# controllers/users/registrations_controller.rb
class Users::RegistrationsController < Devise::RegistrationsController
before_filter :configure_permitted_parameters
protected
# my custom fields are :name
devise_parameter_sanitizer.for(:sign_up) do |u|
u.permit(:name, :major, :email, :password, :password_confirmation)
end
devise_parameter_sanitizer.for(:account_update) do |u|
u.permit(:name, :email, :password, :password_confirmation, :current_password)
end
end
如果我切换config.eager_load = true
到config.eager_load = false
my 中config/environment/production.rb
,我可以成功启动服务器并使用我的应用程序。我认为eager_load
这是生产环境的理想功能,否则默认情况下不会启用它。那么我需要做什么才能让我的应用程序在eager_load
启用的情况下运行,或者我怎样才能找到更多关于它为什么会导致我的服务器崩溃的信息?如果需要其他文件来解决这个问题,请告诉我。
我正在运行 Rails 4 和 Ruby 2.0.0。
感谢您的任何建议!