문제

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)
도움이 되었습니까?

해결책

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

@doc.title().text

다른 팁

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

strip_tags(feed_items_url.title)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top