Skip to main content

Subscribe to GoRails to get access to this episode and all other pro episodes, and new awesome content every month.

Subscribe Now
Only $19/month

Unlimited access. Cancel anytime.

5 Basic Authentication and RSS Feeds

Episode 60 · June 17, 2015

Learn how to add authentication to an RSS feed with Rails and Devise



# index.rss.builder

title       = "GoRails Screencasts"
author      = "Chris Oliver"
description = "GoRails is a series of screencasts and guides for all aspects of Ruby on Rails. Learn how to setup your machine, build a Rails application, and deploy it to a server."
keywords    = "rails, ruby on rails, screencasts, programming, refactoring, coding"
image       = asset_url("itunes.png")

xml.instruct! :xml, version: "1.0"
xml.rss version: "2.0", "xmlns:itunes" => "", "xmlns:media" => "" do do
    xml.title title episodes_url
    xml.description description
    xml.language 'en'
    xml.pubDate @episodes.first.created_at.to_s(:rfc822)
    xml.lastBuildDate @episodes.first.created_at.to_s(:rfc822)
    xml.itunes :author, author
    xml.itunes :keywords, keywords
    xml.itunes :explicit, 'clean'
    xml.itunes :image, :href => image
    xml.itunes :owner do
      xml.itunes :name, author
      xml.itunes :email, '[email protected]'
    xml.itunes :block, 'no'
    xml.itunes :category, text: 'Technology' do
      xml.itunes :category, text: 'Software How-To'
    xml.itunes :category, text: 'Education' do
      xml.itunes :category, text: 'Training'

    @episodes.each do  |episode|
      xml.item do
        xml.summary episode.description
        xml.pubDate episode.created_at.to_s(:rfc822)
        xml.enclosure url: episode.download_url, length: episode.file_size, type: 'video/mp4' episode_url(episode)
        xml.guid({isPermaLink: "false"}, episode.slug)
        xml.itunes :author, author
        xml.itunes :subtitle, truncate(episode.description, length: 150)
        xml.itunes :summary, episode.description
        xml.itunes :explicit, 'no'
        xml.itunes :duration, episode.length


Subscribe or login to view the transcript for this episode.


Wayne Hoover (20 XP) on

Is this functionality on the current site? I'm not seeing it.

Edit, had to enter the url manually:

Chris Oliver (167,500 XP) on

It should be in the top right if you click on "Account" in the navigation too.

Rails Duck on

How do you put in Wistia videos to your Rails Server?????

Chris Oliver (167,500 XP) on

I'm just storing the wistia video ID in Rails and then embedding the videos.

Thomas M (460 XP) on

May I ask how would you implement a simple authentication form (simple password field) to filter private pages, for private photo album/info/etc per say ?
Click the link -> form -> load password protected page if password is true.

Chris Oliver (167,500 XP) on

You could basically store a hashed password on the album and then prompt for the password. When they type in the password, run it through the same hashing algorithm (check out bcrypt) and if the hashes match, you can set a cookie letting the user view the page. This is basically how email/password logins work.

Jeff Dembinski (30 XP) on

Where is it reading the episode data from?

Chris Oliver (167,500 XP) on

@episodes is the instance variable you'd set in the controller just like you normally would when printing out the index.

Jeff Dembinski (30 XP) on

Yes but where, physically are you storing the episodes? Do you keep them on your server, through a hosted service?

Chris Oliver (167,500 XP) on

Oh yeah :) I use Wistia to host them all. They upload them to S3 (or wherever they use) and probably serve the files up through a CDN. I let them handle it but if I were to do it myself I would use S3 and CloudFront probably.

Login or create an account to join the conversation.