Reputation: 13
I'm trying to make a RoR app that parses an RSS feed then digs through it for keywords. To add RSS I'm following this: http://railscasts.com/episodes/168-feed-parsing
And it's not working. I've installed the gem and rebooted the rails server. The config/environment line prevents rake db:migrate from working, giving this error:
/config/environment.rb:7:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)
so I left it out.
The FeedEntry console line, in which I pass the url, gives this error: FeedEntry.update_from_feed("feed://seekingalpha.com/market_currents.xml")
NameError: uninitialized constant FeedEntry::Feedzirra
And the view code gives this error: wrong number of arguments (1 for 0)
with this in the extracted source:
<div class="container-fluid" id="seeking_alpha">
<h3>Seeking Alpha Feed</h3>
<ul class="list-group">
<% for entry in FeedEntry.all(:limit => 10, :order => "published_at desc") %>
<li class="list-group-item"><%= link_to h(entry.title), entry.url %></li>
<% end %>
</ul>
Can you help me fix the problems here? Other than being a complete Rails n00b, I'm guessing my problem is that Feedjira isn't initialized, possibly caused by leaving that line out due to using a newer version of Rails (4.0) and Ruby (2.1.1) than the tutorial does. And perhaps the .xml file format on the feed is also causing a problem. It seems like Feedjira just doesn't want to exist outside of its own model. Any ideas would be very appreciated.
Upvotes: 1
Views: 418
Reputation: 5852
All of your errors stem from omitting that first configuration statement.
If you look at the source code from the Railscast, Ryan defines config
like this in environment.rb:
Rails::Initializer.run do |config|
Though we can't see your environment.rb, your error states you have not defined config
.
Without config
, you can't run migrations, so no FeedEntry
model, hence the errors in your console script and your view. You will also need that statement to use Feedzirra::Feed
in your model-- it has to work.
To recap:
config
in config/environment.rbAlso, this Railscast is old (2009); 'Feedzirra' has been renamed 'Feedjira' and you can add it to your Gemfile:
gem 'feedjira'
You'll have to look at the docs (http://feedjira.com) for any changed functionality in the gem, but that's probably going to be an easier path.
Good luck!
Upvotes: 0