この質問がこのフォーラムで多く寄せられていることは知っていますが、締め切りが厳しく、助けが必要なので、アドバイスをいただければ幸いです。Ruby on Rails は初めてなので、返信する際はその点に注意してください。実行時に mysqlite db の複数のテーブルを更新する rake タスクを作成したいと考えています。これは、データベースに新しいインシデントを作成する移行ファイルです。このすべての情報を CSV ファイル経由で入力する rake タスクを作成するにはどうすればよいですか。rake ファイルを最初から最後まで書くのを手伝ってくれませんか。明らかに、すべての文字列に対してすべてのタスクを記述する必要はありません。いくつかの例を挙げてください。そして、実際の rake ファイルに加えて、アプリの他の部分にコードを追加する必要がありますか (非常に一般的な質問であることは承知していますが、コードを追加する必要がある場合は、場所の一般的な説明をいただければ幸いです)。少しずつ指導が進んでいくと思います。誰かが私からさらに情報が必要な場合は、お尋ねください。
class CreateIncidents < ActiveRecord::Migration
def self.up
create_table :incidents do |t|
t.datetime :incident_datetime
t.string :location
t.string :report_nr
t.string :responsible_party
t.string :area_resident
t.string :street
t.string :city
t.string :state
t.string :home_phone
t.string :cell_phone
t.string :insurance_carrier_name
t.string :insurance_carrier_street
t.string :insurance_carrier_city
t.string :insurance_carrier_state
t.string :insurance_carrier_phone
t.string :insurance_carrier_contact
t.string :policy_nr
t.string :vin_nr
t.string :license_nr
t.string :vehicle_make
t.string :vehicle_model
t.string :vehicle_year
t.timestamps
end
end
def self.down
drop_table :incidents
end
end