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 Rails Concepts:

Basic Authentication and RSS Feeds

Episode 60 · June 17, 2015

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

Authentication


Resources

# 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" => "http://www.itunes.com/dtds/podcast-1.0.dtd", "xmlns:media" => "http://search.yahoo.com/mrss/" do
  xml.channel do
    xml.title title
    xml.link 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]'
    end
    xml.itunes :block, 'no'
    xml.itunes :category, text: 'Technology' do
      xml.itunes :category, text: 'Software How-To'
    end
    xml.itunes :category, text: 'Education' do
      xml.itunes :category, text: 'Training'
    end

    @episodes.each do  |episode|
      xml.item do
        xml.title episode.name
        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'
        xml.link 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
      end
    end
  end
end

Transcripts

Subscribe or login to view the transcript for this episode.

Discussion


Fallback

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

Edit, had to enter the url manually: https://gorails.com/episode...

Fallback

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


Fallback

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

Fallback

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


Fallback

Hey
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.

Fallback

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.


Fallback

Where is it reading the episode data from?

Fallback

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

Fallback

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

Fallback

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.