[Fix #1543] Strip html tags from textarea champs
This commit is contained in:
parent
3156be4d63
commit
3894fc48f6
2 changed files with 43 additions and 0 deletions
16
lib/tasks/2018_03_06_clean_html_textareas.rake
Normal file
16
lib/tasks/2018_03_06_clean_html_textareas.rake
Normal file
|
@ -0,0 +1,16 @@
|
|||
require Rails.root.join("app", "helpers", "html_to_string_helper")
|
||||
|
||||
namespace :'2018_03_06_clean_html_textareas' do
|
||||
task clean: :environment do
|
||||
include ActionView::Helpers::TextHelper
|
||||
include HtmlToStringHelper
|
||||
|
||||
types_de_champ = TypeDeChamp.joins(:champ)
|
||||
.where(type_champ: "textarea")
|
||||
.where("champs.value LIKE '%<%'")
|
||||
|
||||
types_de_champ.find_each do |tdc|
|
||||
tdc.champ.each { |c| c.update_column(:value, html_to_string(c.value)) }
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue