FeedValidator is an interface to the W3C Feed Validation online service based on its SOAP 1.2 support. It helps to find errors in RSS or ATOM feeds. In Rails app this can be done installing the gem.
Step#1
You can install FeedValidator as a gem by writing in gem file:
gem ‘feedvalidator’
Run bundle install to install the gem
Step#2
Include the require ‘feed_validator’ into your controller
Step#3
Create a migration file and edit the file to add the following fields.
class CreateFeeds < ActiveRecord::Migration def self.up create_table :feeds do |t| t.string :title t.timestamps end end def self.down drop_table :feeds end end
Step#4
Validate your feed URL in your controller
def create valid = false site_url = params[:feed][:title].sub(/(\/)+$/,'') begin v = W3C::FeedValidator.new if v.validate_url(site_url) && v.valid? valid = true @feed = Feed.new(:title => site_url, @feed.save end rescue # Do nothing end redirect_to request.referrer end
Advertisements