All Lessons / Basic Authentication and RSS Feeds

Want more GoRails?

GoRails is packed full with over 350 lessons just like this one.

Sign up to get full access or log in to your account and sit back.

Basic Authentication and RSS Feeds

#60 ยท June 17, 2015

Your Teacher

Hi, I'm Chris. I'm the creator of GoRails, and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.

About This Episode

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, ''
    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


logo Created with Sketch.

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

© 2023 GoRails, LLC. All rights reserved.