got why....

I had in my rake task, the only place where I used those models a
require 'sqlitemodel1.rb'
require 'sqlitemodel2.rb'
require 'sqlitemodel3.rb'

this seemed to solve the problems...
but I preferred your solution...
so I removed those requires and changed the models using
establish_connection.......
instead of
ActiveRecord::Base.establish_connection....

now it works but in a cleaner way.

thanks again

On 20 Mag, 10:50, saldan <[email protected]> wrote:
> Thanks Pat,
> actually I leaved everything as is.... and it runs even with
> ActiveRecord::Base.establish_connection ....
>
> don't know why...
>
> but thanks anyway
>
> On 18 Mag, 07:17, Pat Allan <[email protected]> wrote:
>
>
>
> > I think the issue here is that you're changing the overall database 
> > connection, not the one for just this model... try calling 
> > establish_connection within the model, without the class prefix:
>
> >   class Catalog < ActiveRecord::Base
> >     establish_connection(...)
> >   end
>
> > --
> > Pat
>
> > On 13/05/2010, at 5:34 PM, saldan wrote:
>
> > > Hi have some models that has a direct access to sqlite3 database, all
> > > other models use mysql adapter.
> > > something like this
>
> > > class Catalog < ActiveRecord::Base
> > >  ActiveRecord::Base.establish_connection(
> > >    :adapter => "sqlite3",
> > >    :database  => "db/db.sqlite3",
> > >    :encoding => 'utf8'
> > >  )
> > > end
>
> > > All other models use database.yml as configuration that has access
> > > only to MySQL databases.
>
> > > What I do?
>
> > > rake ts:config
>
> > > Message:
> > > (in /Users/daniele/software/rails/ias3/trunk)
> > > ** Invoke ts:config (first_time)
> > > ** Invoke thinking_sphinx:configure (first_time)
> > > ** Invoke thinking_sphinx:app_env (first_time)
> > > ** Execute thinking_sphinx:app_env
> > > ** Invoke environment (first_time)
> > > ** Execute environment
> > > ^[** Execute thinking_sphinx:configure
> > > Generating Configuration to /Users/daniele/software/rails/ias3/trunk/
> > > config/development.sphinx.conf
> > > rake aborted!
> > > Invalid Database Adapter: Sphinx only supports MySQL and PostgreSQL,
> > > not ActiveRecord::ConnectionAdapters::SQLite3Adapter
> > > /Users/daniele/software/rails/ias3/trunk/vendor/plugins/thinking-
> > > sphinx/lib/thinking_sphinx/adapters/abstract_adapter.rb:28:in `detect'
> > > /Users/daniele/software/rails/ias3/trunk/vendor/plugins/thinking-
> > > sphinx/lib/thinking_sphinx/active_record.rb:49:in
> > > `sphinx_database_adapter'
> > > /Users/daniele/software/rails/ias3/trunk/vendor/plugins/thinking-
> > > sphinx/lib/thinking_sphinx/active_record.rb:227:in `to_riddle'
> > > /Users/daniele/software/rails/ias3/trunk/vendor/plugins/thinking-
> > > sphinx/lib/thinking_sphinx/configuration.rb:153:in `build'
> > > /Users/daniele/software/rails/ias3/trunk/vendor/plugins/thinking-
> > > sphinx/lib/thinking_sphinx/configuration.rb:150:in `each'
> > > /Users/daniele/software/rails/ias3/trunk/vendor/plugins/thinking-
> > > sphinx/lib/thinking_sphinx/configuration.rb:150:in `build'
> > > /Users/daniele/software/rails/ias3/trunk/vendor/plugins/thinking-
> > > sphinx/tasks/../lib/thinking_sphinx/tasks.rb:61
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
> > > `execute'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
> > > `execute'
> > > /Users/daniele/.gem/ruby/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'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
> > > `invoke_with_call_chain'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:607:in
> > > `invoke_prerequisites'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in `each'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:604:in
> > > `invoke_prerequisites'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:596:in
> > > `invoke_with_call_chain'
> > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/
> > > 1.8/monitor.rb:242:in `synchronize'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
> > > `invoke_with_call_chain'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
> > > `invoke'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
> > > `invoke_task'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> > > `top_level'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> > > `each'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
> > > `top_level'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> > > `standard_exception_handling'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
> > > `top_level'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
> > > `standard_exception_handling'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
> > > /Users/daniele/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
> > > /usr/bin/rake:19:in `load'
> > > /usr/bin/rake:19
>
> > > Hope you can give me some some hint to make it work...
>
> > > --
> > > 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 
> > > athttp://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 
> > athttp://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 
> athttp://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.

Reply via email to