Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6713265
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:21:32+00:00 2026-05-26T08:21:32+00:00

Background: I am playing around with the feedzirra plugin in a rails app, and

  • 0

Background: I am playing around with the feedzirra plugin in a rails app, and I am attempting to utilize both the feed and entry accessors of the parsed feed in a single view.

To accomplish this, I have created two models: feed and feed_entry. They are as follows:

feed.rb:

class Feed < ActiveRecord::Base
  attr_accessible :title, :url, :feed_url, :last_modified, :guid
  has_many :feed_entries

  def self.update_from_feed(feed_url)
    feed = Feedzirra::Feed.fetch_and_parse(feed_url)
    add_feed(feed)
    FeedEntry.add_entries(feed.entries)
  end


  private

  def self.add_feed(feed)
    unless exists? :guid => feed.id
      create!(
        :title          => feed.title,
        :url            => feed.url,
        :feed_url       => feed.feed_url,
        :last_modified  => feed.last_modified,
        :guid           => feed.id
      )
    end
  end
end

feed_entry.rb:

class FeedEntry < ActiveRecord::Base
  attr_accessible :title, :url, :author, :summary, :content, :published, :guid
  belongs_to :feed

  def self.add_entries(entries)
    entries.each do |entry|
      unless exists? :guid => entry.id
        create!(
          :title        => entry.title,
          :url          => entry.url,
          :author       => entry.author,
          :summary      => entry.summary,
          :content      => entry.content,
          :published    => entry.published,
          :guid         => entry.id
        )
      end
    end
  end
end

Where the intention is to call Feed.update_from_feed(feed_url) as a cron job. In reality, I’m hoping to have the cron job call this function by passing in multiple feeds; but I figured I’d get one working first. For sake of testing, I’m currently calling this function from the console.

Questions:

NoMethodError: undefined method `id' for #<Feedzirra::Parser::RSS:0x00000100bcb0f0>
  1. This may seem very simple, but in calling the update_from_feed function, I get the above error in my console. While new to ruby and rails, I was under the impression that every new entry in a table is given an id that can be referenced – in this scenario, by feed.id. Am I missing something here?

  2. Is my 2-model approach to using this plugin a good direction to go in? Since I’m not able to verify the rest of my approach works until I puzzle out question 1, I thought I’d ask for a tip on best practice in the mean time.

  3. The rest of my plan is to utilize the feed and entry accessors of the plugin within a single controller, and then reference those variables within the relative view somehow. Is this how I should be perceiving the MVC architecture and using it in a RESTful way? If so, how do I reference the feed and entry accessors in the FeedReader view?

This is what the FeedReader controller would look like:

class FeedEntriesController < ApplicationController
  def index
    @feed_entries = FeedEntry.all
    @feeds = Feed.all
  end
end

I know this was a bitch of a post, but any help would really be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:21:33+00:00Added an answer on May 26, 2026 at 8:21 am

    There are a couple of flaws in your approach.

    Firstly, when you update your feed, you are checking whether or not exists (great) but then not dealing with the possibility that it does and then you try to collect new feeds anyway. You need something like;

    feed = Feed.find_by_url(incoming_url) # try loading an existing feed first
    feed = Feedzirra::Feed.fetch_and_parse(feed_url) if !feed # if not, create a new one
    

    Assuming that the last Feedzirra command is the one to create a new feed. I can’t remember!

    The two model idea seems like a sensible approach. When accessing your feeds via the controllers later, you should probably try nested resources. Then your URL would look something like;

    /feed/1/entries
    

    And your controller would be something like;

    @feed = Feed.find(params[:feed_id])
    @entries = @feed.entries
    

    I haven’t answered all your questions, but hopefully it’s a start.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: Our web app uses the jquery.constrain.js plugin to handle data entry in some
Quick background I'm a Java developer who's been playing around with C++ in my
I'm just learning c++ coming from a Java background. Just playing around with simple
I have long programming background, but am new to Python, and am playing around
I'm just playing around with GCD and I've written a toy CoinFlipper app. Here's
I'm playing around with visual controls and colors in a simple background color changing
I've been playing around with Pyramid lately and, coming from a Pylons background, I've
I have been playing around with node.js, and coming from a Java background, I
I'm playing around with the iosched app from Google I/O 2011. Looking at the
I am currently playing around with flex, I have C++ background, so I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.