Hi, I have 2 database for my application "development1" and "development2". My default database is "development1". But I have to update the "contacts" table which is in "davelopment2". So I know that I have to use the "establish_connection" to establish a connection with the "development2". I am doing like this " ActiveRecord::Base.establish_connection( :adapter => "mysql" , :host => "localhost" , :database => "railsdatabase" , :username => "railsusername" , :password => "railspassword" )" contact=Contact.find(2) contact.name="Tushar Gandhi" contact.save" Whether it will point to the "contacts" table of "development2" database. Whether this will work? beacuse I haven''t made any connection reference for "contacts" code. Can anyone please help me out for this. Thanks, Tushar -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
If you are always going to CRUD contacts in development2, then you can set the connection on the model: in contact.rb class Contact < ActiveRecord::Base establish_connection(:development2) end in database.yml: development2: adapter: mysql host: localhost database: railsdatabase username: railsusername password: railspassword -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Sharagoz. Yes it makes sense, to add the configuraion on model level. Sharagoz -- wrote:> If you are always going to CRUD contacts in development2, then you can > set the connection on the model: > > in contact.rb > class Contact < ActiveRecord::Base > establish_connection(:development2) > end > > > in database.yml: >-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
How do we open a read-only connection to the second database development2 ? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.