I'm on Rails 3.2.21 and Thinking-Sphinx 3.1.4 using Sphinx 2.2.9-id64-release (rel22-r5006).
I just moved over from mysql to postgres and when I index I get this error:
production@vagrant:/opt/rails/production/current$ rake ts:index --trace
** Invoke ts:index (first_time)
** Invoke environment (first_time)
** Execute environment
** [Raven] Raven 0.13.3 ready to catch errors
** Execute ts:index
Generating configuration to /opt/data/production-schedule/sphinx/development.sphinx.conf
rake aborted!
ActiveRecord::ConfigurationError: #<Proc:0x007f8daccfec20@/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/filter_reflection.rb:57 (lambda)>
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:131:in `build'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:24:in `block in graft'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:22:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/associations/join_dependency.rb:22:in `graft'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:364:in `build_joins'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:266:in `build_arel'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation/query_methods.rb:260:in `arel'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activerecord-3.2.21/lib/active_record/relation.rb:459:in `to_sql'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_builder.rb:11:in `sql_query'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:119:in `build_sql_query'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:135:in `prepare_for_render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/active_record/sql_source.rb:65:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `block in render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `collect'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration/index.rb:29:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/core/index.rb:57:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `block in render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `collect'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/riddle-1.5.12/lib/riddle/configuration.rb:43:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:93:in `render'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:99:in `block in render_to_file'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/open-uri.rb:36:in `open'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/open-uri.rb:36:in `open'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/configuration.rb:99:in `render_to_file'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/rake_interface.rb:24:in `configure'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/rake_interface.rb:35:in `index'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/thinking-sphinx-3.1.4/lib/thinking_sphinx/tasks.rb:9:in `block (2 levels) in <top (required)>'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
/home/production/.rbenv/versions/2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:78:in `block in run'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/home/production/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/home/production/.rbenv/versions/2.1.2/bin/rake:23:in `load'
/home/production/.rbenv/versions/2.1.2/bin/rake:23:in `<main>'
Tasks: TOP => ts:index
I narrowed down the index to the only two entries which can cause the error, it seems related to polymorphic relationships:
ThinkingSphinx::Index.define(:project, name: 'project', with: :active_record, delta: true) do
indexes data.itemcode, as: :itemcode
polymorphs data, to: PROJECT_DATA_TYPES.map(&:camelize)
end
Any idea why this is not working?
Going by your stacktrace, you're using Rails 3.2 and Thinking Sphinx 3.1.4 - polymorphic association support for Rails 3.2 was dropped in TS v3.1.4 (as covered in the 'Upgrading' section of the release notes). The ActiveRecord internal code changes regularly, and it's just been too painful to support 3.2 alongside 4.x for that specific feature.
If you've only just upgraded TS and had an earlier version that worked, you may want to switch back to that. Or upgrade to Rails 4.0? :)