search for: establish_connect

Displaying 20 results from an estimated 250 matches for "establish_connect".

2006 Aug 13
1
establish_connection method
I''m digging into rails source code. But I''ve got a problem in undestading actionrecord::base source code which is connection_specification.rb. In the body of establish_connection method, def self.establish_connection(spec = nil) case spec when nil raise AdapterNotSpecified unless defined? RAILS_ENV establish_connection(RAILS_ENV) when ConnectionSpecification clear_active_connection_name @active_connection...
2006 Feb 08
8
Strategies for Unit testing 2 databases
...ections as needed at runtime, and spanning relationships across the databases (which really impressed me). The problem is, I can''t seem to force Units for these models (that use a secondary db) to load their fixtures into and use the secondary database. I tried applying this: Project.establish_connection(:test_group) (where :test_group is a database connection defined in database.yml) at various locations within the test itself, and test_helper.rb... but my unit is failing with this error: ActiveRecord::StatementInvalid: Mysql::Error: Table ''scoot_test.projects'' doesn'&...
2006 Mar 16
5
Multiple databases + switching databases
...ould I do this choice at runtime? Is there a way to set table name in environment.rb file dynamically? Is there another way to switch the database without setting environment.rb? I''ve tried to do this just setting connection at Gps class but it didn''t work. ( ActiveRecord::Base.establish_connection( :adapter => "firebird", :host => "localhost", :database => customer_name, :username => "SYSDBA", :password => "masterkey") Does anybody have any idea? Thanks a lot! Marcia -- Posted via http://www.ruby-forum.com/.
2011 Jul 19
2
ActiveRecord::Base.establish_connection in development and production envs
...#39;'ve resque workers in my application. These workers do several jobs that associated with DB. In development environment, I''ve no need to provide some additional configuration for db, they are use development database. But then I switching to production env, I set ActiveRecord::Base.establish_connection with my production DB parameters. Problem: When I''m switch back to development env, I''ve to comment ActiveRecord::Base.establish_connection every time. Hope, anybody can help me and provide a better approach for this situation. Sincerely, Nikolay Burlov. -- You received thi...
2006 May 15
8
Databases... write master, multiple read-only slaves.. will this work?
...write to one database and read from another. From what I''ve read, Rails doesn''t do this out of the box. I came up with something that does work, but I''m wondering if there is something I''m missing in the code below that''s going to bite me, such as establish_connection creating a huge number of objects as time progresses. Or is there a better way to flip the connection back and forth? The below does work though. Writes do go to :writemaster and reads go to :readslave... Comments? class MyModel < ActiveRecord::Base #..... def before_save...
2012 May 15
5
setting up the SQLite database
...obvious'' way to set up an SQLite (or other) database and its location per-app. I''ve got a bit lost with the Camping 2 changes and various code snippets I have kicking around. 1. is it best to set up the DB creation/connection: 1.1 at the end of the app AppName::Models::Base.establish_connection( :adapter => ''sqlite3'', :database => ''/path/to/my/app/myApp.db'' ) run AppName #from an old snippet 1.2 OR like this (postgres) example [Magnus]: def List.create List::Models::Base.establish_connection( :adapter => "postgresql",...
2006 Jan 18
1
Helps!!!!! Rails database connection guru needed!!!!!!!
...important questions that we did find the answer from the documentation, So we hope the communauty can help us to answer those questions!!!!! Question A- How rails disconnect the connection? As we can see in the source code : Call stack for postgresql 1- any controller 2- connectionspecification.establish_connection 3- ActiveRecord::base.postgresql_connection(config) 4- ConnectionAdapters::PostgreSQLAdapter.new( PGconn.connect(), logger ) 5- connection_specification.establish_connection @@defined_connections[self] = spec The connection is made while Rails calls PGconn.connect(), then the connectionstored...
2007 Apr 04
4
joining across databases in a find statement with include (legacy db)
Hi, I have a legacy database ''old'' and a new database ''new'' which rails uses. I set up models using old with establish_connection(old), and this works well, except for include: class OldModel < ActiveRecord::Base establish_connection(old) end class NewModel < ActiveRecord::Base has_one :old_model end a = OldModel.find :first NewModel.find(:all, :include => :old_model) will give an error like Mysql::Error:...
2006 Oct 12
2
Too Many Mysql connections
In my app, for three models: foo,bar and baz, the database connection is made to a different database and hence in model code: class Foo < ActiveRecord::Base establish_connection :diff_database end class Bar < ActiveRecord::Base establish_connection :diff_database end class Baz < ActiveRecord::Base establish_connection :diff_database end Now, the problem is, if is use the above code, not one but three connections to another database is made and it seems that...
2009 Jan 13
2
Connect multiple DB in rails project using AR
...se connection is defined in database.yml. There is a table call "servers" which have about 40 records, which is a collection of database setting (i.e. Server.name, Server.port, Server.host) I know the way to establish multiple connection as below... class A < ActiveRecord::Base end A.establish_connection(a) # a is the database config class B < ActiveRecord::Base end B.establish_connection(b) # b is the database config # repeat and repeat....... However, how can I do this in a block? I have no idea to do so...Please give me some light. all_servers = Server.find(:all) all_servers.each do |...
2012 Aug 31
1
after_fork - ActiveRecord::AdapterNotSpecified
Hi all, I''m fighting with the after_fork hook and my sinatra application. The Sinatra app is using active_record, In my unciron.rb file I''m using preload_app true after_fork do |server, worker| ? defined?(ActiveRecord::Base) and ??? ActiveRecord::Base.establish_connection End but I always get the error: ERROR -- : ActiveRecord::AdapterNotSpecified (ActiveRecord::AdapterNotSpecified) I''m using unicorn (4.3.1), sinatra (1.3.2), activerecord (3.2.6), ruby 1.9.3p194 The app (test.rb): require ''rubygems'' require ''sinatra''...
2006 Jun 16
0
Mysql: establish_connection''...development database not conf
...t have failed so far: This is a cpanel server running Mysql 4.1.19, fcgi with apache. Here is the output from script/console Loading development environment. /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:194:in `establish_connection'':ActiveRecord::AdapterNotSpecified: development database is not configured database.yml: development: adapter: mysql database: polydis_todolistdev username: polydis_polydis password: ****** host: localhost test: adapter: mysql database: polydis_todolisttest username: polydis_polydis...
2007 Jul 19
0
locomotive and establish_connection
I am using locomotive for development. My app uses dual databases and hence I have a model that uses a different establish_connection to connect to the db. It seems that locomotive does not support this. Am I correct? If so, does anyone have a different approach to achieve this? thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby...
2006 Jan 24
4
Parse request URL.
Hello all. Due to the mistakes of the company before I joined ;) I am stuck with a multiple database setup. I am planning on parsing the REQUEST_URL to decide which controller is being accessed and basing the establish_connection on that. Before I go messing around with regexps I was wondering if rails has a built in function for parsing URLS. I have googled around a bit and seen net/http but I cannot find an API for it. Thanks Jeff -- Posted via http://www.ruby-forum.com/.
2012 Jul 17
6
Database connection parameters are tied to the filesystem
...s/rails/issues/5297 which explains the issue/solution far better then I could. Active record supports this natively, I can''t see why rails would force the requirement of a database.yml and for it to have a "production" section. see http://apidock.com/rails/ActiveRecord/Base/establish_connection/class URL section. Regards David -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/8qOi7BryxukJ. To post to this group, send email to...
2006 Feb 27
5
Database connections...so many connections!
...bases), I moved the code from the application controller into each controller (as I thought it was prettier / easier / simpler ) . In each controller is the following code: class XYZController < ApplicationController before_filter :change_database def change_database ActiveRecord::Base.establish_connection( :adapter => "oci", :database => "", :host => "******", :username => "******", # Differs between controller :password => "********" # Differs between controller ) end The problem is that with almost...
2006 Jan 19
4
multiple database in the same actions?
Hi, I read the example in http://wiki.rubyonrails.com/rails/pages/HowtoUseMultipleDatabases, it show us how to connect to other database, each time we start a new action, however, this doesn''t work while you try to connect to two different database within the same action. SO I wonder is it possible to bind to two or more database within the same action???? Thanks you very much Saiho
2006 Jun 19
4
share model definition
I want to share everything about a model except the db connection. Is this a reasonable way to do it? module NotebookDefinition -- Posted via http://www.ruby-forum.com/.
2007 Jan 22
4
Postamble vs campingrc
Hi, Should I be able to use the Webrick postamble instead of using .campingrc, to tell Camping I want to use mysql? It doesn''t seem to be working for me. It does work however, when I''m using FastCGI (establish_connection :adapter => ''mysql''). James
2006 Aug 01
7
MySQL binding problem on Max OS X 10.4
...ml: development: adapter: mysql database: test_v1_development username: root password: ***** host: localhost 3. I put the following code into the environment.rb file in the Rails::Initializer section: # test database # printf "Establishing DB connection.." ActiveRecord::Base.establish_connection puts "ok!" puts "Testing DB connection .." begin tables = ActiveRecord::Base.connection.select_all(''SHOW TABLES'') rescue => err puts ''===== database connection failed ====='' puts "Missing database bindings for #{err.blamed_files...