Insert into table without his model

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

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

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:

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.