date = Date.today
query = "insert into custom_reports(name,description,created_at) values(#{report_name}, #{report_content}, #{date})"
ActiveRecord::Base.connection.execute(query);
它插入
0000-00-00 00:00:00
所以想到了采用mysql时间戳的方式。可以吗?
请您参考如下方法:
这应该可行
query = "insert into custom_reports(name,description,created_at) values('#{report_name}', '#{report_content}', '#{Time.now}')"