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?
I got the answer,
connection = ActiveRecord::Base.connection
ActiveRecord::Base.connection.execute("SQL query")
we can perform any query in Rails.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.