Using sanitize within a Rails controller

后端 未结 3 1984
时光说笑
时光说笑 2020-12-25 12:49

I\'m trying to call sanitize within a controller. Here\'s what I tried:

class FooController < ApplicationController
  include ActionView::Hel         


        
3条回答
  •  Happy的楠姐
    2020-12-25 13:14

    Rails 6:

    To strip links (for example) from a text, just call:

    ...
    Rails::Html::LinkSanitizer.new.sanitize("links here will be stripped")
    ...
    

    see https://github.com/rails/rails-html-sanitizer

提交回复
热议问题