Database problems when setting up Phusion Passenger for the first time
I'm a new ruby/rails user trying to get my mac set up for the first time with an existing rails project. The app runs fine when using mongrel, but it doesn't start properly when using Phusion Passenger.
The problem seems to be when loading the first model of the project. I'm speculating that there's a problem accessing my database, but I don't know why.
Something is different between my mongrel and passenger configurations. Possibly rvm is pointing to the wrong thing? Perhaps my gems are different somehow? Perhaps my mysql gem isn't installed properly? Or maybe my railsenv is wrong somehow? I don't really know, any ideas?
Below you'll find the error as well as my various configuration files.
Expected /Users/mike/Projects/XXX/XXX/app/models/user/identity.rb to define User::Identity
0 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 426 in `load_missing_constant'
1 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 96 in `const_missing'
2 /Users/mike/Projects/XXX/XXX/app/models/user.rb 22
3 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 380 in `load_without_new_constant_marking'
4 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 380 in `load_file'
5 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 521 in `new_constants_in'
6 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 379 in `load_file'
7 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 259 in `require_or_load'
8 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 425 in `load_missing_constant'
9 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 80 in `rake_original_const_missing'
10 /Users/mike/Projects/XXX/XXX/vendor/gems/rake-0.8.7/lib/rake.rb 2503 in `const_missing'
11 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 92 in `const_missing'
12 /Users/mike/Projects/XXX/XXX/spec/factories/point_allocation_factory.rb 1
13 /Users/mike/.rvm/rubies/ree-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 31 in `gem_original_require'
14 /Users/mike/.rvm/rubies/ree-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 31 in `require'
15 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 156 in `require'
16 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 521 in `new_constants_in'
17 /Users/mike/Projects/XXX/XXX/vendor/rails/activesupport/lib/active_support/dependencies.rb 156 in `require'
18 /Users/mike/Projects/XXX/XXX/vendor/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb 300 in `find_definitions'
19 /Users/mike/Projects/XXX/XXX/vendor/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb 299 in `each'
20 /Users/mike/Projects/XXX/XXX/vendor/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb 299 in `find_definitions'
21 /Users/mike/Projects/XXX/XXX/vendor/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb 295 in `each'
22 /Users/mike/Projects/XXX/XXX/vendor/gems/factory_girl-1.2.3/lib/factory_girl/factory.rb 295 in `find_definitions'
23 /Users/mike/Projects/XXX/XXX/config/environments/development.rb 26
24 /Users/mike/Projects/XXX/XXX/vendor/rails/railties/lib/initializer.rb 592 in `call'
25 /Users/mike/Projects/XXX/XXX/vendor/rails/railties/lib/initializer.rb 592 in `after_initialize'
26 /Users/mike/Projects/XXX/XXX/vendor/rails/railties/lib/initializer.rb 591 in `each'
27 /Users/mike/Projects/XXX/XXX/vendor/rails/railties/lib/initializer.rb 591 in `after_initialize'
28 /Users/mike/Projects/XXX/XXX/vendor/rails/railties/lib/initializer.rb 177 in `process'
29 /Users/mike/Projects/XXX/XXX/vendor/rails/railties/lib/initializer.rb 113 in `send'
30 /Users/mike/Projects/XXX/XXX/vendor/rails/railties/lib/initializer.rb 113 in `run'
31 /Users/mike/Projects/XXX/XXX/config/environment.rb 12
32 /Users/mike/.rvm/rubies/ree-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 31 in `gem_original_require'
33 /Users/mike/.rvm/rubies/ree-1.8.7-2010.01/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb 31 in `require'
34 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb 303 in `preload_application'
35 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb 252 in `initialize_server'
36 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/utils.rb 255 in `report_app_init_status'
37 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb 237 in `initialize_server'
38 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb 194 in `start_synchronously'
39 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb 163 in `start'
40 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/railz/application_spawner.rb 213 in `start'
41 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb 262 in `spawn_rails_application'
42 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb 126 in `lookup_or_add'
43 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb 256 in `spawn_rails_application'
44 /Users/mike/.rvm/gems/开发者_运维技巧ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb 80 in `synchronize'
45 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server_collection.rb 79 in `synchronize'
46 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb 255 in `spawn_rails_application'
47 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb 154 in `spawn_application'
48 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/spawn_manager.rb 287 in `handle_spawn_application'
49 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb 352 in `__send__'
50 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb 352 in `main_loop'
51 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/lib/phusion_passenger/abstract_server.rb 196 in `start_synchronously'
52 /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/bin/passenger-spawn-server 61
.profile
if [[ -s /Users/mike/.rvm/scripts/rvm ]] ; then source /Users/mike/.rvm/scripts/rvm ; fi
httpd.conf
LoadModule passenger_module /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /Users/mike/.rvm/gems/ree-1.8.7-2010.01/gems/passenger-2.2.11
#PassengerRuby /Users/mike/.rvm/rubies/ree-1.8.7-2010.01/bin/ruby
PassengerRuby /Users/mike/.rvm/bin/passenger_ruby
RailsEnv development
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot /Library/WebServer/Documents
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName XXX.local
DocumentRoot /Users/mike/Projects/XXX/XXX/public/
<Directory /Users/mike/Projects/XXX/XXX/public/>
AllowOverride all
Options -MultiViews
Allow from all
</Directory>
</VirtualHost>
/etc/hosts
127.0.0.1 XXX.local
Frameworks
- Default mac apache installation
- Passenger (installed like so: http://www.modrails.com/install.html)
- rvm (rvm --default ree; rvm gemset create XXX; echo "rvm ree@XXX;" > /Users/mike/Projects/XXX/XXX/.rvmrc)
- ree (rvm install ree)
- mysql 5.1.46 64 from dmg (gem install mysql -- --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include)
The problem was in my ~/.rvm/bin/passenger_ruby file. For some reason the GEM_PATH and PATH included ree-1.8.7-2010.01 and ree-1.8.7-2010.01@global, but did NOT include ree-1.8.7-2010.01@XXX which is where I had installed all my gems.
Adding ree-1.8.7-2010.01@XXX to both the GEM_PATH and PATH fixed the problem. I don't know if there's a better solution.
精彩评论