Sourabh Upadhyay
Sourabh Upadhyay

Reputation: 1044

insert data into table by sql in rails3

I'm stuck in this scenario:

I've a table(it is not a model) and want to insert data in it via Rails.

For example:

Table name:  Last updates
fields:  another_table_id:integer, last_time:datetime

I want to insert data into this?

Upvotes: 0

Views: 67

Answers (1)

Sourabh Upadhyay
Sourabh Upadhyay

Reputation: 1044

I got the answer,

connection = ActiveRecord::Base.connection
ActiveRecord::Base.connection.execute("SQL query") 

we can perform any query in Rails.

Upvotes: 1

Related Questions