0

I have an app that successfully builds on my local system, but when deployed to Heroku, or run with rails server -e production yields:

=> 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>'

My environment.rb is

# Load the Rails application. 
require File.expand_path('../application', __FILE__)

# Initialize the Rails application.
OldManager::Application.initialize!

And the registrations_controller.rb is

# 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

If I switch config.eager_load = true to be config.eager_load = false in my config/environment/production.rb, I can successfully start the server and use my application. I assume eager_load is a desirable feature for a production environment, otherwise it wouldn't be enabled by default. So what do I need to do to allow my app to run with eager_load enabled, or how can I find out more about why it is causing my server to crash? If other files are necessary in order to figure this out, please let me know.

I am running Rails 4 and Ruby 2.0.0.

Thanks for any advice!

  • Did you get it fixed @user1483188 , I do have the same problem when I make eager_load = true I got server crash with an error(not the error you mentioned I got different) , I could run the server only when I make to false.if you fixed that error please let me know – ratnakar Mar 25 '15 at 04:14

1 Answers1

0

The error is:

uninitialized constant Users (NameError)

Take a look on your controller's declaration..

Oswaldo Ferreira
  • 1,339
  • 16
  • 15