이 질문은이 포럼에서 많이 묻지 만 엄격한 기한을 지키고 있으며 도움이 필요하므로 조언이 필요합니다. 나는 Ruby on Rails에 익숙하지 않으므로 응답 할 때 염두에 두시기 바랍니다. 실행될 때 mysqlite db의 여러 테이블을 업데이트하는 rake 작업을 만들고 싶습니다. 이것은 db에 새 인시던트를 만드는 마이그레이션 파일입니다. 이 모든 정보를 CSV 파일을 통해 입력하는 레이크 작업을 어떻게 만듭니 까? 누군가가 처음부터 끝까지 갈퀴 파일을 쓰는 데 도움이 될 수 있습니까? 분명히 모든 문자열에 대해 모든 작업을 작성할 필요가 없으며 몇 가지 예제 만 제공하십시오. 그리고 실제 레이크 파일 외에도, 내 앱의 다른 부분에 코드를 추가해야합니까 (매우 일반적인 질문 인 것을 알고 있습니다. 코드를 추가해야하는 경우 어디에서 일반적인 설명을 읽어 주어야합니다). 나는 약간의 인도가 길을 갈 것이라고 느낍니다. 누군가 나에게서 더 이상의 정보가 필요하면 그냥 물어보십시오. lib 디렉토리/작업에서 프로젝트 폴더 아래레이크 작업을 통해 CSV 파일을 가져올 수 있습니까?
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
이 유용하다 .... > http://stackoverflow.com/questions/3346108/how-to-write-rake-task-to-import- data-to-rails-app –