Domanda

I'm using Feedjira (Feedzirra) https://github.com/feedjira/feedjira to parse rss feeds in rails.

I need a way to remove html tags from the title of the rss feed items before I save to database.

in my create method which saves the feed item to the database

:title => feed_items_url.title

I tried to add simple_format to this but it didn't work

:name => simple_format(feed_items_url.title)
È stato utile?

Soluzione

Use nokogiri and the method text which will strip the HTML tags from your content.

@doc.title().text

Altri suggerimenti

Rails has a built-in helper for strip HTML tags: strip_tags.

strip_tags(feed_items_url.title)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top