Hi everyone, I've come across an unusual problem, I have many models
(Pages, Links etc...) that are associated with a central class called
ComponentInstance. It's a polymorphic association.

To delete one of these elements from the system I call destroy on the
component_instance which then is set (Through the association) to
delete the instance (the page or link etc...). This works well, but
even since I added delta indexing (on the timestamp) things break.
Rails will delete the page but halt at the component instance. It
seems that it's trying to update the delta and fails because half of
the association is missing. I've tried suspended_delta and even
suspended_delta(false) but no luck there. Here's the error and trace:
The indexes code is at the bottom:

undefined method `>' for nil:NilClass

/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
whiny_nil.rb:52:in `method_missing'
/Library/Ruby/Gems/1.8/gems/ts-datetime-delta-1.0.2/lib/
thinking_sphinx/deltas/datetime_delta.rb:93:in `toggled'
/Users/brendon/.gem/ruby/1.8/gems/thinking-sphinx-1.3.14/lib/
thinking_sphinx/active_record/delta.rb:28:in `toggled_delta?'
/Users/brendon/.gem/ruby/1.8/gems/thinking-sphinx-1.3.14/lib/
thinking_sphinx/active_record.rb:342:in `toggle_deleted'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:93:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:92:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:92:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:92:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:276:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
callbacks.rb:344:in `callback'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
callbacks.rb:338:in `destroy_without_transactions'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:229:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:229:in `with_transaction_returning_status'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/database_statements.rb:136:in
`transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:182:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:228:in `with_transaction_returning_status'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:192:in `destroy'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations/association_proxy.rb:217:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations/association_proxy.rb:217:in `method_missing'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
associations.rb:1495:in `belongs_to_dependent_destroy_for_instance'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:178:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:178:in `evaluate_method'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:166:in `call'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:93:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:92:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:92:in `send'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:92:in `run'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
callbacks.rb:276:in `run_callbacks'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
callbacks.rb:344:in `callback'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
callbacks.rb:338:in `destroy_without_transactions'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:229:in `send'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:229:in `with_transaction_returning_status'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/database_statements.rb:136:in
`transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:182:in `transaction'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:228:in `with_transaction_returning_status'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
transactions.rb:192:in `destroy'
/Users/brendon/Projects/SpikeAtSchool/app/controllers/
component_instances_controller.rb:165:in `destroy'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:1331:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:1331:in `perform_action_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:617:in `call_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:610:in `perform_action_without_benchmark'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
1.8/benchmark.rb:308:in `realtime'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.5/lib/active_support/
core_ext/benchmark.rb:17:in `ms'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
benchmarking.rb:68:in `perform_action_without_rescue'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
rescue.rb:160:in `perform_action_without_flash'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
flash.rb:146:in `perform_action'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:532:in `send'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:532:in `process_without_filters'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
filters.rb:606:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:391:in `process'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
base.rb:386:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
routing/route_set.rb:437:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:87:in `dispatch'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:121:in `_call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:130:in `build_middleware_stack'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
string_coercion.rb:25:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
string_coercion.rb:25:in `call'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/
rack/head.rb:9:in `call'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/
rack/methodoverride.rb:24:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
params_parser.rb:15:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
session/abstract_store.rb:122:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
query_cache.rb:29:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/query_cache.rb:34:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
query_cache.rb:9:in `cache'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
query_cache.rb:28:in `call'
/Library/Ruby/Gems/1.8/gems/activerecord-2.3.5/lib/active_record/
connection_adapters/abstract/connection_pool.rb:361:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
failsafe.rb:26:in `call'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/
rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/
rack/lock.rb:11:in `synchronize'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/vendor/rack-1.0.0-git/lib/
rack/lock.rb:11:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:114:in `call'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
reloader.rb:34:in `run'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.5/lib/action_controller/
dispatcher.rb:108:in `call'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/rack/
request_handler.rb:95:in `process_request'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_request_handler.rb:207:in `main_loop'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
railz/application_spawner.rb:378:in `start_request_handler'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
railz/application_spawner.rb:336:in `handle_spawn_application'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
utils.rb:183:in `safe_fork'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
railz/application_spawner.rb:334:in `handle_spawn_application'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server.rb:352:in `__send__'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server.rb:352:in `main_loop'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server.rb:196:in `start_synchronously'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server.rb:163:in `start'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
railz/application_spawner.rb:213:in `start'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
spawn_manager.rb:262:in `spawn_rails_application'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server_collection.rb:126:in `lookup_or_add'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
spawn_manager.rb:256:in `spawn_rails_application'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server_collection.rb:80:in `synchronize'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server_collection.rb:79:in `synchronize'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
spawn_manager.rb:255:in `spawn_rails_application'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
spawn_manager.rb:154:in `spawn_application'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
spawn_manager.rb:287:in `handle_spawn_application'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server.rb:352:in `__send__'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server.rb:352:in `main_loop'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/lib/phusion_passenger/
abstract_server.rb:196:in `start_synchronously'
/Library/Ruby/Gems/1.8/gems/passenger-2.2.5/bin/passenger-spawn-server:
61

The setup is as follows:

  #Thinking Sphinx
  define_index do
    for entity in Entity.all
      Page.connection.change_database!(entity.domain_hash)

      define_source do
                indexes :name
                indexes :body, :as => :description

        has component_instance.deleted_on, :as => :deleted_on
        has component_instance.deleted_root_item, :as
=> :deleted_root_item
        has component_instance.component.backend_only, :as
=> :backend_only

        has '(SELECT `entity_id` FROM `site_settings` LIMIT 1)', :as
=> :entity_id, :type => :integer

        where 'deleted_on IS NULL AND deleted_root_item IS NULL'

        set_property :delta => :datetime, :threshold => 1.hour

      end
    end
end


I thought that perhaps the delta wouldn't bother doing anything
because this is a timestamp delta that should only run when I call it
from the command line, but it seems to call the standard code anyway?

I delved deeper into script/console and tried to delete the
component_instance there to see if there's a clearer error but it's
still the same.

I'm using the latest versions of both the delta gem and ts gem as of
today. :)

Hope someone can help :D

Brendon
-- 
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.


Reply via email to