From 3992ba64be92be14fc22ee352382449dbde13cc4 Mon Sep 17 00:00:00 2001 From: viktorvsk Date: Thu, 23 Apr 2026 04:51:47 +0000 Subject: [PATCH] feat: handle word_file upload in create action --- app/controllers/words_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index bb6959a..03f5463 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -14,7 +14,13 @@ class WordsController < ApplicationController end def create - raw = params[:word_list].to_s.strip + 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