2016-06-08 56 views
1

我試圖用如何添加iframe到ruby on rails 4.2.6中的sanitized標籤?

config.action_view.sanitized_allowed_tags 

我試圖找到什麼標籤都已經使用控制檯允許的iframe添加到santized標籤。

[email protected]:~/workspace/corse (master) $ heroku run rails c 
Running rails c on ⬢ fa4... up, run.9396 
Loading production environment (Rails 4.2.6) 
irb(main):001:0> puts helper.sanitized_allowed_tags.to_a 
NoMethodError: undefined method `sanitized_allowed_tags' for #<ActionView::Base:0x007f18ea91ea60> 
     from /app/vendor/bundle/ruby/2.3.0/gems/metamagic-3.1.7/lib/metamagic/view_helper.rb:30:in `method_missing' 
     from (irb):1 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:110:in `start' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/console.rb:9:in `start' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:68:in `console' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands/commands_tasks.rb:39:in `run_command!' 
     from /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.6/lib/rails/commands.rb:17:in `<top (required)>' 
     from /app/bin/rails:8:in `require' 
     from /app/bin/rails:8:in `<main>' 
irb(main):002:0> 

任何想法如何添加它而不忽略其他標籤?由於

回答

2

請對下面的例子看看:

module Tapp 
    class Application < Rails::Application 
    # In config/application.rb 
    config.action_view.sanitized_allowed_tags = ['strong', 'em', 'a', 'br', 'iframe'] 
    # ... 
end 

我的應用程序稱爲Tapp,我敢肯定你會在這裏有另外一個名字;)

然後在控制檯:

[[email protected] ~/workspace/tapp]$ rc 
Loading development environment (Rails 4.2.6) 
[1] pry(main)> Tapp::Application.config.action_view[:sanitized_allowed_tags] 
=> ["strong", "em", "a", "br", "iframe"]