mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 07:10:12 +01:00
Better error messages
This commit is contained in:
parent
c2bd1b0d81
commit
511a4a23b6
3 changed files with 4 additions and 6 deletions
|
|
@ -62,8 +62,8 @@ class DataController < ApplicationController
|
|||
flash[:notice] = t 'data.import.projects_count', count: count
|
||||
when 'todos'
|
||||
count = Todo.import path_and_file, params, current_user
|
||||
if not count
|
||||
flash[:error] = t('data.import.errors.invalid_destination')
|
||||
if ! count
|
||||
flash[:error] = t('data.import.errors.no_context')
|
||||
else
|
||||
flash[:notice] = t 'data.import.todos_count', count: count
|
||||
end
|
||||
|
|
|
|||
|
|
@ -353,10 +353,7 @@ class Todo < ApplicationRecord
|
|||
|
||||
def self.import(filename, params, user)
|
||||
default_context = user.contexts.order('id').first
|
||||
if default_context.nil?
|
||||
logger.error "No available contexts in import"
|
||||
return FALSE
|
||||
end
|
||||
return false if default_context.nil?
|
||||
|
||||
count = 0
|
||||
CSV.foreach(filename, headers: true) do |row|
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue