You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 23, 2021. It is now read-only.
I have a column on which you can find the object in the database, such as "handle"
I correctly write the code to see if this object already exists, then update its attributes, if it is not, create a new one?
The text was updated successfully, but these errors were encountered:
Offered wrap it in your gem.
For example, you can add an option to update the model for the column in which the values are unique, and the parameter to check for the existence of pass through getter method in class import.
class EmployeeImporter < ActiveImporter::Base
imports Employee
column 'First name', :first_name
column 'Last name', :last_name
column 'Department', :department do |department_name|
Department.find_by(name: department_name)
end
transfer params to block check_update
check_update 'First name'
end
in the file ' active_importer / lib / active_importer / base.rb'
def check_update(check_column = false)
if check_column
# start find model by unique column
# if model exists, then start update_attributes
end
end
if you tell me how to write an update attributes, I wrap everything and do commit
I have a column on which you can find the object in the database, such as "handle"
I correctly write the code to see if this object already exists, then update its attributes, if it is not, create a new one?
The text was updated successfully, but these errors were encountered: