From 9cf68c99b7ceb5de6eca26fe4975b3fca6d6d7d1 Mon Sep 17 00:00:00 2001 From: Victor Kavunenko Date: Mon, 6 Oct 2014 10:40:14 +0300 Subject: [PATCH 1/2] FIX: force encoding for title field Job exception: incompatible character encodings: UTF-8 and ASCII-8BIT -- This exception rise up for correct(!) UTF-8 cyrillic (in my case, but non-latin overall, I suppose) in title field during RSS polling (feed polling url) and breaks topics creation. So, just force_encoding() makes it work. --- app/models/search_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/search_observer.rb b/app/models/search_observer.rb index 24d8548bd..e73ee42ba 100644 --- a/app/models/search_observer.rb +++ b/app/models/search_observer.rb @@ -41,7 +41,7 @@ class SearchObserver < ActiveRecord::Observer end def self.update_posts_index(post_id, cooked, title, category) - search_data = scrub_html_for_search(cooked) << " " << title + search_data = scrub_html_for_search(cooked) << " " << title.force_encoding('UTF-8') search_data << " " << category if category update_index('post', post_id, search_data) end From 1a52dba3af53f005e463fb47000f42327ecabc7e Mon Sep 17 00:00:00 2001 From: Victor Kavunenko Date: Mon, 6 Oct 2014 12:45:11 +0300 Subject: [PATCH 2/2] due to travis error message: can't modify frozen string --- app/models/search_observer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/search_observer.rb b/app/models/search_observer.rb index e73ee42ba..78233b249 100644 --- a/app/models/search_observer.rb +++ b/app/models/search_observer.rb @@ -41,7 +41,7 @@ class SearchObserver < ActiveRecord::Observer end def self.update_posts_index(post_id, cooked, title, category) - search_data = scrub_html_for_search(cooked) << " " << title.force_encoding('UTF-8') + search_data = scrub_html_for_search(cooked) << " " << title.dup.force_encoding('UTF-8') search_data << " " << category if category update_index('post', post_id, search_data) end