Hi, I have "contacts" table. I have to insert and update "contacts" table. Is that be possible to do this without having the "contact.rb" model? Can I make direct interaction to the "contacts" table? Can anyone help me out? Thanks, Tushar Gandhi -- 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.
On Feb 10, 12:53 pm, Tushar Gandhi <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > I have "contacts" table. > I have to insert and update "contacts" table. > > Is that be possible to do this without having the "contact.rb" model? > > Can I make direct interaction to the "contacts" table? >Well ActiveRecord::Base.connection.execute lets you execute arbitrary sql queries, but (except perhaps in the case of bulk inserts) why would you want to rewrite what is already in Active Record ? Fred> Can anyone help me out? > > Thanks, > Tushar Gandhi > -- > Posted viahttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks Fred,
Actually my "contacts" table is in other database.
Means I have two databases "development1" and
"development2". My main
database is "development1". My contacts table reside in
"development2".
So I have writtes like this
establish_connection(:development2)
@contact=ActiveRecord::Base.connection.execute("select * from
contacts where id=1")
Still it is givng me error that "ERROR: Mysql::Error: Table
development1.contacts'' doesn''t exist"
Can you tell me what is wrong with this?
Thanks,
Tushar Gandhi
Frederick Cheung wrote:> > Fred
--
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.
Is there a good reason you want to skip the model? if contact.rb looks like this: class Contact < ActiveRecord::Base establish_connection(:development2) end then you can do this in the controller@contact = Contact.find(1) and it will fetch contacts from development 2. -- 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.