mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-21 22:54:09 +01:00
fix import for csv
This commit is contained in:
parent
76902e95c0
commit
a31c0a7a5d
5 changed files with 41 additions and 21 deletions
|
|
@ -393,11 +393,11 @@ class Todo < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def self.import(params, user)
|
||||
default_context = Context.where(:user_id=>user.id).order('id').first
|
||||
def self.import(filename, params, user)
|
||||
default_context = user.contexts.order('id').first
|
||||
|
||||
count = 0
|
||||
CSV.foreach(params[:file], headers: true) do |row|
|
||||
CSV.foreach(filename, headers: true) do |row|
|
||||
unless find_by_description_and_user_id row[params[:description].to_i], user.id
|
||||
todo = new
|
||||
todo.user = user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue