A CSV import needs to compare a column of data to an indexed string value which are number literals:
The import_csv task
@model = row[0]
@article = Article.where(['model = ?', @model.to_i]).first
is thus attempting to compare the integer from the csv file to a string ad returning.
LINE 1: ...T "articles".* FROM "articles" WHERE (model = 1410) LI...
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "articles".* FROM "articles" WHERE (model = 1406) LIMIT 1'
01406, ,0,0,1,0,0,RASATO,,408
Error importing row because 'PG::UndefinedFunction: ERROR: operator does not exist: character varying = integer
Note: comparing string on string
@article = Article.where(['model = ?', @model]).first
'Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id'
Is there any way of effecting the comparison, short of saving an indexed value of the string-defined variable?
Aucun commentaire:
Enregistrer un commentaire