0
Railsプロジェクトで独自のSQLクエリを作成しようとしています。何を試しても、created_atのフォーマットについて不満を持ち続けます。SQLクエリの問題とcreated_atの正しい書式
current_time = Time.current
values = attribute_values.map { |attribute| "(#{current_item.id},#{attribute},#{current_time},#{current_time})" }.join(',')
ActiveRecord::Base.connection.execute("INSERT INTO line_item_attributes (line_item_id, product_attribute_id, created_at, updated_at) VALUES #{values}")
はエラーを返します:レールログの
PG::SyntaxError - ERROR: syntax error at or near "18"
SQLクエリは次のようになります。
INSERT INTO line_item_attributes (line_item_id, product_attribute_id, created_at, updated_at) VALUES (76,12398,2016-07-13 18:35:30 +0200,2016-07-13 18:35:30 +0200),(76,12394,2016-07-13 18:35:30 +0200,2016-07-13 18:35:30 +0200)
は、どのように私は、これは、保存するための適切なフォーマットで入手できますか?