Okay, Heroku has added a flag which optionally makes the environment
variables available
during asset compilation. This way the db can be correctly loaded.
However its an unofficial experimental feature so far.
Works fine for me though.

On 9 Nov., 14:10, nico <[email protected]> wrote:
> Hmm, maybe after all this is not a thinking sphinx issue. I found the
> same database dependence in another app that doesn't use ts. But it
> also uses observers.
> It seems the model loading requires a db connection to replace and
> quote interpolation values in scope condition for example. I submitted
> a ticket to Heroku about this, asking them
> if they can remove the database independency requirement for asset
> compilation.
>
> On 9 Nov., 03:25, Pat Allan <[email protected]> wrote:
>
>
>
>
>
>
>
> > In theory, yes - except there's been cases where people are setting 
> > different db connection details either side of the define_index block, so 
> > the context *at the time of definition* matters. I guess it'd be possible 
> > to have a flag set when that rake task is called, and toggle accordingly - 
> > though that's just another layer of complication.
>
> > Will keep all of this in mind as I work through the rewrite.
>
> > --
> > Pat
>
> > On 09/11/2011, at 1:42 AM, nico wrote:
>
> > > Wouldn't it be sufficient for thinking sphinx to do the db stuff only
> > > when running the indexing tasks?
>
> > > On 8 Nov., 12:19, Pat Allan <[email protected]> wrote:
> > >> It's probably because the Observers are loaded, which means the models 
> > >> are loaded, which means the index definitions are loaded - and they 
> > >> check the db settings at the time of definition.
>
> > >> --
> > >> Pat
>
> > >> On 08/11/2011, at 5:06 PM, nico wrote:
>
> > >>> Yep, that works... ;-)
>
> > >>> On 8 Nov., 11:06, nico <[email protected]> wrote:
> > >>>> Ah, okay, thanks Pat, that sounds like a workaround! Will try it out.
>
> > >>>> The weird thing is that the db requirements are only there when using
> > >>>> the observers. I don't understand why...
>
> > >>>> Nico
>
> > >>>> On 7 Nov., 19:16, Pat Allan <[email protected]> wrote:
>
> > >>>>> Sorry Nico, nothing yet… it's hard to avoid the db requirements.
>
> > >>>>> Maybe you can only set observers if ENV['RAILS_GROUPS'] isn't set to 
> > >>>>> assets?
>
> > >>>>> --
> > >>>>> Pat
>
> > >>>>> On 07/11/2011, at 4:25 PM, nico wrote:
>
> > >>>>>> Anyone any ideas here?
>
> > >>>>>> On 5 Nov., 16:28, nico <[email protected]> wrote:
> > >>>>>>> Sure:
>
> > >>>>>>> config.active_record.observers = [:company_cache_observer,
> > >>>>>>>                                     :layout_cache_observer,
> > >>>>>>>                                       :user_observer,
> > >>>>>>>                                 :userpoints_observer,
> > >>>>>>>                                 :ownership_observer]
> > >>>>>>> On 5 Nov., 16:13, Pat Allan <[email protected]> wrote:
>
> > >>>>>>>> Hi Nico
>
> > >>>>>>>> Can you show us how you're loading the observers in your 
> > >>>>>>>> application.rb file?
>
> > >>>>>>>> --
> > >>>>>>>> Pat
>
> > >>>>>>>> On 05/11/2011, at 4:02 PM, nico wrote:
>
> > >>>>>>>>> Strangely, thinking sphinx's model loading in define_index 
> > >>>>>>>>> triggers a
> > >>>>>>>>> database connection to be established when the model with 
> > >>>>>>>>> define_index
> > >>>>>>>>> is observed by an observer.
>
> > >>>>>>>>> This causes rake tasks like assets:precompile to depend on a db
> > >>>>>>>>> connection which should normally not be required. This dependency
> > >>>>>>>>> makes asset compilation on Heroku fail. If I remove the observer
> > >>>>>>>>> loading in application.rb, the database dependency does't exist 
> > >>>>>>>>> and
> > >>>>>>>>> rake tasks work fine without a db configured.
>
> > >>>>>>>>> It's quite hard to debug this, help is greatly appreciated! Here 
> > >>>>>>>>> is
> > >>>>>>>>> the stack trace for rake assets:precompile when rails is 
> > >>>>>>>>> configured
> > >>>>>>>>> with a non existing database and using observers:
>
> > >>>>>>>>> bundle exec rake assets:precompile RAILS_ENV=staging --trace
> > >>>>>>>>> ** Invoke assets:precompile (first_time)
> > >>>>>>>>> ** Execute assets:precompile
> > >>>>>>>>> /Users/nico/.rvm/rubies/ruby-1.9.2-p290/bin/ruby 
> > >>>>>>>>> /Users/nico/.rvm/gems/
> > >>>>>>>>> ruby-1.9.2-p290/bin/rake assets:precompile:all RAILS_ENV=staging
> > >>>>>>>>> RAILS_GROUPS=assets --trace
> > >>>>>>>>> ** Invoke assets:precompile:all (first_time)
> > >>>>>>>>> ** Execute assets:precompile:all
> > >>>>>>>>> ** Invoke assets:precompile:primary (first_time)
> > >>>>>>>>> ** Invoke assets:environment (first_time)
> > >>>>>>>>> ** Execute assets:environment
> > >>>>>>>>> ** Invoke environment (first_time)
> > >>>>>>>>> ** Execute environment
> > >>>>>>>>> rake aborted!
> > >>>>>>>>> FATAL:  database "non_existing_database" does not exist
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/postgresql_adapter.rb:1032:in
> > >>>>>>>>> `initialize'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/postgresql_adapter.rb:1032:in 
> > >>>>>>>>> `new'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/postgresql_adapter.rb:1032:in
> > >>>>>>>>> `connect'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/postgresql_adapter.rb:301:in
> > >>>>>>>>> `initialize'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/postgresql_adapter.rb:28:in 
> > >>>>>>>>> `new'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/postgresql_adapter.rb:28:in
> > >>>>>>>>> `postgresql_connection'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:304:in
> > >>>>>>>>> `new_connection'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:323:in
> > >>>>>>>>> `checkout_new_connection'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:265:in
> > >>>>>>>>> `block (2 levels) in checkout'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:261:in
> > >>>>>>>>> `loop'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:261:in
> > >>>>>>>>> `block in checkout'
> > >>>>>>>>> /Users/nico/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:
> > >>>>>>>>> 201:in `mon_synchronize'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:260:in
> > >>>>>>>>> `checkout'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:162:in
> > >>>>>>>>> `connection'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_pool.rb:409:in
> > >>>>>>>>> `retrieve_connection'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_specification.rb:
> > >>>>>>>>> 107:in `retrieve_connection'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/connection_adapters/abstract/connection_specification.rb:
> > >>>>>>>>> 89:in `connection'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/base.rb:1473:in `replace_bind_variables'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/base.rb:1460:in `sanitize_sql_array'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/base.rb:1366:in `sanitize_sql_for_conditions'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/relation/query_methods.rb:259:in `build_where'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/relation/query_methods.rb:124:in `where'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activerecord-3.1.1/lib/
> > >>>>>>>>> active_record/base.rb:444:in `where'
> > >>>>>>>>> /Users/nico/Rails/myapp/app/models/user.rb:194:in `<class:User>'
> > >>>>>>>>> /Users/nico/Rails/myapp/app/models/user.rb:100:in `<top 
> > >>>>>>>>> (required)>'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:240:in `require'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:240:in `block in require'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:225:in `load_dependency'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:240:in `require'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:348:in `require_or_load'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:489:in `load_missing_constant'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:181:in `block in const_missing'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
> > >>>>>>>>> active_support/dependencies.rb:179:in `each'
> > >>>>>>>>> /Users/nico/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/
>
> ...
>
> Erfahren Sie mehr »

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