Hi Brad
Not quite sure why Rails doesn't load the full environment for the db:seed
task. But beside that, I want to focus on the second error first - have you
added the delta column to your model? If so, then Rails is definitely doing
something odd.
Let me know.
Cheers
--
Pat
On 07/04/2011, at 10:22 AM, Brad Langhorst wrote:
> I have a model (Organism) that is indexed with using thinking_sphinx
>
> define_index do
> indexes :name
> indexes :aliases
> indexes :short_name
>
> set_property :delta => :delayed
> end
>
> I've added this in my seeds.rb
>
> org = Organism.find_or_create_by_name("Unknown")
> org.creator ||= admin
> org.organism_type ||= ot
> org.taxon_id ||= 32644
> org.save!
>
> This can't work because rake db:seed doesn't know what define_index
> means.
>
> So I added some requires at the top of seeds.rb
> require 'thinking_sphinx' # needed to instantiate indexed objects
> (e.g. Organism)
> require 'thinking_sphinx/deltas/delayed_delta'
>
> ugly...
> and just shifts the problem to
>
> undefined method `delta' for #<Organism:0x105cd2e58>
>
> Anybody faced this issue? Suggestions?
>
>
> Here's the stack trace
>
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.11/lib/active_record/
> attribute_methods.rb:260:in `method_missing'
> /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.4.4/lib/thinking_sphinx/
> deltas/default_delta.rb:27:in `send'
> /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.4.4/lib/thinking_sphinx/
> deltas/default_delta.rb:27:in `toggled'
> /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.4.4/lib/thinking_sphinx/
> active_record/delta.rb:45:in `index_delta'
> /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.4.4/lib/
> thinking_sphinx.rb:231:in `any?'
> /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.4.4/lib/thinking_sphinx/
> active_record/delta.rb:44:in `each'
> /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.4.4/lib/thinking_sphinx/
> active_record/delta.rb:44:in `any?'
> /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.4.4/lib/thinking_sphinx/
> active_record/delta.rb:44:in `index_delta'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:178:in `send'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:178:in `evaluate_method'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:166:in `call'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:93:in `run'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:92:in `each'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:92:in `send'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:92:in `run'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> callbacks.rb:276:in `run_callbacks'
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.11/lib/active_record/
> callbacks.rb:344:in `callback'
> /Library/Ruby/Gems/1.8/gems/after_commit-1.0.8/lib/after_commit/
> connection_adapters.rb:129:in `send'
> /Library/Ruby/Gems/1.8/gems/after_commit-1.0.8/lib/after_commit/
> connection_adapters.rb:129:in `trigger_after_commit_callbacks'
> /Library/Ruby/Gems/1.8/gems/after_commit-1.0.8/lib/after_commit/
> connection_adapters.rb:128:in `each'
> /Library/Ruby/Gems/1.8/gems/after_commit-1.0.8/lib/after_commit/
> connection_adapters.rb:128:in `trigger_after_commit_callbacks'
> /Library/Ruby/Gems/1.8/gems/after_commit-1.0.8/lib/after_commit/
> connection_adapters.rb:36:in `commit_db_transaction'
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.11/lib/active_record/
> connection_adapters/abstract/database_statements.rb:159:in
> `transaction_without_callback'
> /Library/Ruby/Gems/1.8/gems/after_commit-1.0.8/lib/after_commit/
> connection_adapters.rb:12:in `transaction'
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.11/lib/active_record/
> transactions.rb:182:in `transaction'
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.11/lib/active_record/
> transactions.rb:200:in `save!'
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.11/lib/active_record/
> transactions.rb:208:in `rollback_active_record_state!'
> /Library/Ruby/Gems/1.8/gems/activerecord-2.3.11/lib/active_record/
> transactions.rb:200:in `save!'
> /Users/langhorst/Documents/PolBase/source/db/seeds.rb:40
> /Library/Ruby/Gems/1.8/gems/declarative_authorization-0.5.2/lib/
> declarative_authorization/maintenance.rb:30:in
> `without_access_control'
> /Users/langhorst/Documents/PolBase/source/db/seeds.rb:6
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> dependencies.rb:171:in `load_without_new_constant_marking'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> dependencies.rb:171:in `load'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> dependencies.rb:547:in `new_constants_in'
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.11/lib/active_support/
> dependencies.rb:171:in `load'
> /Library/Ruby/Gems/1.8/gems/rails-2.3.11/lib/tasks/databases.rake:223
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
> `invoke_with_call_chain'
> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
> 1.8/monitor.rb:242:in `synchronize'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
> `invoke_with_call_chain'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
> `invoke_task'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> `standard_exception_handling'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> `standard_exception_handling'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
> /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31
> /usr/bin/rake:19:in `load'
>
> --
> 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.
>
--
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.