This is just a warning, not an error - everything should still work. Thinking Sphinx has gone with Rails' expectations of objects matching the directory structure for auto-loading, but your Userable concern does not (there'd be no warning if it was under app/concerns, instead of app/models/concerns).
This issue is dealt with for Thinking Sphinx v3, as index definitions get their own files, instead of being placed within models. If you're giving TS v3 a try, you should read both of these pages: https://groups.google.com/d/msg/thinking-sphinx/QM0BlS3gg3k/s61pfCBBTUoJ https://github.com/pat/thinking-sphinx/blob/edge/README.textile Cheers -- Pat On 07/01/2013, at 1:13 AM, Роман Будников wrote: > Got bug when using Thinking Sphinx and models what include concerns like in > #398-service-objects (RailsCasts) > > card.rb > ``` ruby > # coding: utf-8 > class Card < ActiveRecord::Base > include Userable > > ... > #Sphinx search > define_index do > indexes :name > indexes :text > has :card_way_id, :card_type_id, :card_mode_id > set_property :delta => true > end > end > ``` > > concerns/userable.rb > ``` ruby > module Userable > extend ActiveSupport::Concern > > included do > attr_accessible :user_id > > belongs_to :user > > validates :user_id, presence: true > validates :user_id, numericality: { only_integer: true }, > if: lambda{|m| !m.user_id.nil? } > end > end > ``` > > ``` ruby > Warning: Error loading > /home/roma/rails/discount/app/models/concerns/userable.rb: > uninitialized constant Concerns::Userable > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:230:in > `block in constantize' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in > `each' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/inflector/methods.rb:229:in > `constantize' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.9/lib/active_support/core_ext/string/inflections.rb:54:in > `constantize' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:64:in > `block (2 levels) in load_models' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in > `each' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:54:in > `block in load_models' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in > `each' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:53:in > `load_models' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/context.rb:15:in > `prepare' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:81:in > `block in context' > <internal:prelude>:10:in `synchronize' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx.rb:78:in > `context' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/thinking-sphinx-2.0.13/lib/thinking_sphinx/active_record.rb:166:in > `define_index' > /home/roma/rails/discount/app/models/card.rb:40:in `<class:Card>' > /home/roma/rails/discount/app/models/card.rb:2:in `<top (required)>' > (irb):1:in `irb_binding' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/workspace.rb:80:in > `eval' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/workspace.rb:80:in > `evaluate' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/context.rb:254:in > `evaluate' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:159:in `block (2 > levels) in eval_input' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:273:in > `signal_status' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:156:in `block in > eval_input' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:243:in > `block (2 levels) in each_top_level_statement' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in > `loop' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:229:in > `block in each_top_level_statement' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in > `catch' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb/ruby-lex.rb:228:in > `each_top_level_statement' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:155:in > `eval_input' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:70:in `block in > start' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `catch' > /home/roma/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/irb.rb:69:in `start' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:47:in > `start' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands/console.rb:8:in > `start' > /home/roma/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.9/lib/rails/commands.rb:41:in > `<top (required)>' > script/rails:6:in `require' > script/rails:6:in `<main>' > ``` > > -- > You received this message because you are subscribed to the Google Groups > "Thinking Sphinx" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/thinking-sphinx/-/rTIyezRSLSIJ. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/thinking-sphinx?hl=en. -- You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
