[英]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
. 我有一张
table(it is not a model)
,想通过Rails
在其中插入数据。
For example: 例如:
Table name: Last updates
fields: another_table_id:integer, last_time:datetime
I want to insert data into this? 我要插入数据吗?
I got the answer, 我得到了答案,
connection = ActiveRecord::Base.connection
ActiveRecord::Base.connection.execute("SQL query")
we can perform any query in Rails. 我们可以在Rails中执行任何查询。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.