mongoid / mongoid-grid_fs

A pure Mongoid/Moped implementation of the MongoDB GridFS specification.
Other
83 stars 50 forks source link

mongoid-grid_fs / delayed_job / thinking_sphinx clash #33

Closed jan closed 10 years ago

jan commented 10 years ago

Seems like mongoid-grid_fs, delayed_job and thinking_sphinx are not getting along.

When I restart delayed_job, I get the following error:

Warning: Error loading /home/deploy/.bundler/our_project/ruby/1.9.1/gems/mongoid-grid_fs-1.9.0/lib/mongoid-grid_fs.rb:
uninitialized constant Home
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `each'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `constantize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:64:in `block (2 levels) in load_models'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in `each'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in `block in load_models'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in `each'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in `load_models'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:15:in `prepare'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:81:in `block in context'
<internal:prelude>:10:in `synchronize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:78:in `context'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/active_record.rb:166:in `define_index'
/srv/www/our_project/releases/20131106143153/app/models/category.rb:12:in `<class:Category>'
/srv/www/our_project/releases/20131106143153/app/models/category.rb:1:in `<top (required)>'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:230:in `block in constantize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `each'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:229:in `constantize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/inflector/methods.rb:260:in `safe_constantize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/activesupport-3.2.11/lib/active_support/core_ext/string/inflections.rb:66:in `safe_constantize'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/params_wrapper.rb:152:in `_default_wrap_model'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/params_wrapper.rb:169:in `_set_wrapper_defaults'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/metal/params_wrapper.rb:133:in `inherited'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/actionpack-3.2.11/lib/abstract_controller/railties/routes_helpers.rb:7:in `block (2 levels) in with'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/actionpack-3.2.11/lib/action_controller/railties/paths.rb:7:in `block (2 levels) in with'
/srv/www/our_project/releases/20131106143153/app/controllers/categories_controller.rb:1:in `<top (required)>'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in `each'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:438:in `block in eager_load!'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in `each'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/engine.rb:436:in `eager_load!'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
/home/deploy/.bundler/our_project/ruby/1.9.1/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
/srv/www/our_project/releases/20131106143153/config/environment.rb:5:in `<top (required)>'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
/usr/local/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
script/delayed_job:17:in `<main>'

I did not experience this issue before I added grid_fs to my Gemfile.

I don't have a class Home by the way and Category's thinking_sphinx block reads:

app/models/category.rb

define_index do # line 12
  indexes :name

  where "categories.name NOT LIKE 'Sonstige %'"
end

So no idea where "Home" come's from. Also unsure who's to blame here.

rmm5t commented 10 years ago

It's hard to say without being able to search your codebase. This is going to be a tough one to help you debug otherwise.

ahoward commented 10 years ago

@jan you should be able to debug this easily

rails swallows errors loading gems but you will seem them and can debug with this approach

i am 99.99% certain you are hitting a RAILS_ENV=production 'feature' of mongoid that pre-loads all models when running in production mode

you also seem to have a mix of RDMS and mongoid models, which is a potential cause of issues too

in any case, i'll bet 100 buckets it's not mongoid_grid_fs, but it's loading of mongoid, which in turn slurps in all models (iff in production mode) that you are seeing. this is a simply load order issue triggered by preloading in proudction and should be simple to fix.

rmm5t commented 10 years ago

Closing due to lack of activity.