Validating RSS Feeds in Rails

Rails1
Social sharing

Rails1FeedValidator is a gem which validates the RSS feeds through SOAP protocol of the W3C Feed Validation service. It helps to find out errors in RSS or ATOM feeds. In Rails app we can do the feed validation by installing the gem.

    Step#1
  • Install the FeedValidator as a gem:
gem feedvalidator

Run the bundler to install the gem
Step#2

  • Include the require ‘feed_validator’ into your controller
  • Step#3

  • Generate 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
    site_url = params[:feed][:title].sub(/(\/)+$/,'')
    begin
    v = W3C::FeedValidator.new
    if v.validate_url(site_url) && v.valid?
    @feed = Feed.new(:title => site_url)
    @feed.save
    end
    rescue
    # Do nothing
    end
    redirect_to request.referrer
    end

    Your recently viewed posts:

    Jayadev Das - Post Author

    Do what you do best in – that’s what I’ve always believed in and that’s what I preach. Over the past 25+ years (yup that’s my expertise ‘n’ experience in the Information Technology domain), I’ve been consulting to small, medium and large companies ‘About Web Technologies, Mobile Future as well as on the good-and-bad of tech. Blogger, International Business Advisor, Web Technology Expert, Sales Guru, Startup Mentor, Insurance Sales Portal Expert & a Tennis Player. And top of all – a complete family man!

      Contact Us

      We’d love to help & work with you




      When do you want to start ?


      Enter your email address to stay up to date with the latest news.
      Holler Box

      Orange Exit pop up

      Subscribe for the latest
      trends in web and
      mobile app development
      Holler Box

      Exit pop up

      Sad to see you leaving early...

      From "Aha" to "Oh shit" we are sharing everything on our journey.
      Enter your email address to stay up to date with the latest news.
      Holler Box