mardi 3 octobre 2017

Undefined method html_safe for Nokogiri Html Document

I am trying to use .html_safe in the below description where I receive the error as Undefined method for Nokogiri HTML document.

blogs_controller.rb

@blog = Blog.find(19)
@description = Nokogiri::HTML.parse(@blog.description)
@description.search('a.fr-file').each do |desc|
  desc['href']= File.join(ActionController::Base.asset_host, desc['href'])
end

show.html.erb

<p><%= @description.html_safe %></p>

Kindly advise.

Aucun commentaire:

Enregistrer un commentaire