![](/img/trans.png)
[英]How to export table data as CSV file in Ruby 1.9.2 + Rails3?
[英]insert data into table by sql in rails3
我陷入這種情況:
我有一張table(it is not a model)
,想通過Rails
在其中插入數據。
例如:
Table name: Last updates
fields: another_table_id:integer, last_time:datetime
我要插入數據嗎?
我得到了答案,
connection = ActiveRecord::Base.connection
ActiveRecord::Base.connection.execute("SQL query")
我們可以在Rails中執行任何查詢。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.