Comments (3)
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
from active_importer.
I try like this code, but it is not best way, can you help write best?
on :row_processing do
p = Product.find_by_handle(row['handle'])
attrs = {}
attrs = { handle: row['handle'], title: row['title'], ............. next params ........... }
unless p.nil?
p.update_attributes attrs
skip_rows_if { true }
end
end
This code work, but this is bullshit :(
from active_importer.
sorry, i find answer in wiki :)
https://github.com/continuum/active_importer/wiki/Update-instead-of-create
from active_importer.
Related Issues (20)
- Gem required error - google_drive HOT 2
- Returning a summary message HOT 2
- Skip completely empty rows by default HOT 4
- Headers errors kill the process HOT 5
- Ability to specify the model to import to. HOT 8
- Blank 'last column' header causes fatal error. HOT 4
- Number in cell add decimal number HOT 1
- Model should not be save if not changed HOT 2
- Populate information without to specify all the column names HOT 2
- Import multiple .xls sheets HOT 9
- Problem when import xlsx -> Ole::Storage::FormatError - OLE2 signature is invalid HOT 3
- ActiveRecord::RecordInvalid HOT 1
- Import values without headers HOT 3
- Case insensitive headers HOT 3
- Transactional ActiveRecord::RecordInvalid rescue? HOT 5
- CSV delimiter HOT 3
- custom helper preprocesor HOT 4
- Import same model from excel with unknown sheets number HOT 3
- RuntimeError - Duplicate importer column HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from active_importer.