Helmeloh's Tumblr RSS

Archive

Jun
21st
Tue
permalink
Rails 3.0.6+ If you use auto_link to mark up links in your text, you can add the rel=”nofollow” attribute like this: auto_link(@text, :html => { :rel => ‘nofollow’ }) However, if you also want to use simple_format: simple_format(@text) you can’t combine this by default: simple_format(auto_link(@text, :html => { :rel => ‘nofollow’ })) because then the rel=”nofollow” will be filtered by the sanitation initiated by simple_format. So, you can either tell it to don’t do sanitation or just add this into a config/initializer: MyApp::Application.config.after_initialize do |config| ActionView::Base.sanitized_allowed_attributes = ‘rel’
end This should work too (but doesn’t for me all times): MyApp::Application.config.action_view.sanitized_allowed_attributes = ‘rel’ Then this should work: simple_format(auto_link(@text, :html => { :rel => ‘nofollow’ }))
  1. helmeloh reblogged this from rfc2822 and added:
    Another Web Developer’s Notes: simple_format,
  2. rfc2822 posted this