Reputation: 297
I have a csv import function that is creating many cardrequests for each id in the csv. I have a has many through relationship for the cardholdergroup model. How do I tell this create action to create the records and set the cardholdergroup_ids: [] param on create?
CSV.foreach(file_path) do |row|
@cardrequest = Cardrequest.create(empid: row[0],
startdate: cardrequest_params[:startdate],
enddate: cardrequest_params[:enddate], user_id: current_user.id,
cardholdergroup_ids: cardrequest_params[cardholdergroup_ids: []
end
Upvotes: 0
Views: 27