Javascript で JSON 形式のレコードの配列を生成しました。コントローラーで複数のレコードを作成したいと考えています。これらのデータを渡します:
[
{"trip_id":0,"arrival_time":0,"departure_time":0,"stop_id":0,"stop_sequence":0},{"trip_id":1,"arrival_time":1,"departure_time":1,"stop_id":1,"stop_sequence":1},
{"trip_id":2,"arrival_time":2,"departure_time":2,"stop_id":2,"stop_sequence":2},{"trip_id":3,"arrival_time":3,"departure_time":3,"stop_id":3,"stop_sequence":3},
{"trip_id":4,"arrival_time":4,"departure_time":4,"stop_id":4,"stop_sequence":4},{"trip_id":5,"arrival_time":5,"departure_time":5,"stop_id":5,"stop_sequence":5},
{"trip_id":6,"arrival_time":6,"departure_time":6,"stop_id":6,"stop_sequence":6},{"trip_id":7,"arrival_time":7,"departure_time":7,"stop_id":7,"stop_sequence":7},
{"trip_id":8,"arrival_time":8,"departure_time":8,"stop_id":8,"stop_sequence":8},{"trip_id":9,"arrival_time":9,"departure_time":9,"stop_id":9,"stop_sequence":9}
]
私は多かれ少なかれこのようにしようとしています:
def create
params.each do |stop_time|
StopTime.create stop_time
end
...
、しかし、各レコードを取得する方法がわかりません (:id ? または他の何か?)。
ありがとう、
ドミニク