整理するために、次のファイルが必要ですdb/seeds/countries.rb
。
ActiveRecord::Base.connection.execute(IO.read("db/sql/countries_iso3166.sql"))
そして、このファイルdb/sql/countries_iso3166.sql
にはSQLがあり、サーバーに貼り付けると正常に実行されますが、実行すると次のrake db:seed
ようになります。
Mysql2::Error: You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near
'INSERT INTO `countries` (`code`, `alpha2`, `alpha3`, `langCS`, `langDE`, `langEN'
at line 34:
これらは 34 行目と 35 行目です。
34 INSERT INTO `countries` (`code`, `alpha2`, `alpha3`, `langCS`, `langDE`, `langEN`,
`langES`, `langFR`, `langIT`, `langNL`) VALUES
35 (4, 'AF', 'AFG', 'Afghanistán', 'Afghanistan', 'Afghanistan', 'Afganistán',
'Afghanistan', 'Afghanistan', 'Afghanistan'),