feat: handle word_file upload in create action
This commit is contained in:
parent
e9f5d8ece2
commit
3992ba64be
@ -15,6 +15,12 @@ class WordsController < ApplicationController
|
||||
|
||||
def create
|
||||
raw = params[:word_list].to_s.strip
|
||||
|
||||
if params[:word_file].present?
|
||||
file_content = params[:word_file].read.force_encoding("UTF-8")
|
||||
raw = "#{raw}\n#{file_content}".strip
|
||||
end
|
||||
|
||||
lines = raw.split("\n").map(&:strip).reject { |l| l.blank? || l.start_with?("#") }
|
||||
|
||||
imported = 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user