Reputation: 24078
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:
TransactionImport
(row) + TransactionImportField
(cell).TransactionImport(Field)
.TransactionImport
into 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.
Upvotes: 0
Views: 130
Reputation: 142014
REST/HTTP has no expectation that doing POST will only create one record. That maybe the default rails behaviour, but you should not constrain your design because of that.
Upvotes: 1