Hi,
I have the model:
User -1---n- Transaction(amount,description, date)User -1---n- TransactionImport -1---n- TransactonImportField(name,value)
(personal expense tracking app).
What I want to achieve is this:
- User opens URL and pastes the CSV with the list of transactions.
- User submits it.
- System extracts data from CSV into
TransactionImport(row) +TransactionImportField(cell). - User can choose which column means what (amount, description, date) from the imported data in
TransactionImport(Field). - User click save and the system transfers
TransactionImportinto the Transaction.
What I can't seem to get right is the fact that step 3 creates multiple records of TransactionImport (and related TransactionImportField).
So doing POST /transaction_imports?csv=abcd is expected to produce one record if we would be RESTful. But the code is supposed to be something like this:
# TransactionImportsController
def create
result = TransactionImports.parse(params[:csv])
flash[:notice] = result.message
redirect_to transaction_imports_path
end
I am probably approaching the task from a wrong angle as I feel that implementation doesn't fit in tp the inherited_resources.
Could you please advise what would be the most conventional way of implementing this?
Thanks,
Dmytrii.