Comments (3)
Hi @8frogs, sorry for the late response:
So if i understand correctly, you would to have access to a external context inside the Importer class right? For example, the session.
Currently i think what you could do is create a Decorator object that holds the User
and the extra data you need, and use the UserImporter class normally since it should work with a PORO.
I will review a better way of doing this tho, maybe passing a context to the importer would be a nice feature to add.
Because even tho now you can override the persist
method on the Importer, i don't think you can add parameters to it yet.
Hope i was of help! :)
from smuggle.
To add to Pablo's response, if you want to perform additional model modifications depending on the imported data, it is recommended to do so in the attribute defined on the Importer, e.g.
# Capitalize the name if the CSV column "capitalize" contains the string "true"
class UserImporter < Smuggle::Importer::Base
attributes :name
def name
if row[:capitalize] == "true"
row[:name].capitalize
else
row[:name]
end
end
end
Let us know if we answered your question, and if you have any more questions!
from smuggle.
Closing this due to inactivity
from smuggle.
Related Issues (7)
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 smuggle.