# RSS Feed parsing problem

**URL:** <https://www.ruby-forum.com/t/rss-feed-parsing-problem/165341>\
**Category:** Rails\
**Created:** [April 12, 2009, 6:59pm UTC](https://www.ruby-forum.com/t/rss-feed-parsing-problem/165341 "2009-04-12T18:59:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [April 12, 2009, 6:59pm UTC](https://www.ruby-forum.com/t/rss-feed-parsing-problem/165341/1 "2009-04-12T18:59:29Z")

</div>

I want to parse multiple feeds but i have ran into problems

Im doing a query on a table which returns rss feed urls stored in an  
instance variable called @urls .

with each of these eed urls i want to parse them like below

@feeds = SimpleRSS.parse open(@urls.feed\_url)

however this only works when doing a query for first or last and not  
find:all. eg: just 1 feed url

undefined method `feed\_url’ for #Array:0x7f97c3f4faf8

any suggestions on what the problem is? ive tried the approach of trying  
to put this into a loop but had no luck and are struggling to find a  
solution

Regards

nick

---

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [April 12, 2009, 9:35pm UTC](https://www.ruby-forum.com/t/rss-feed-parsing-problem/165341/2 "2009-04-12T21:35:14Z")

</div>

On 12 Apr., 18:59, Nick H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> find:all. eg: just 1 feed url
> 
> undefined method `feed\_url’ for #Array:0x7f97c3f4faf8
> 
> any suggestions on what the problem is? ive tried the approach of trying  
> to put this into a loop but had no luck and are struggling to find a  
> solution

To me the problem is pretty obvious. You are trying to call an  
undefined method ‘feed\_url’ on an Array. To make this work you should  
call the method on each of the items in the Array individually. Like  
this:

@feeds = []  
@urls.each do |url|  
@feeds \<\< SimpleRSS.parse open(url.feed\_url)  
end

You need to know, that whenever you’re asking ActiveRecord for  
multiple records in the database, they will always come back as an  
Array with each item representing a record or model. But when you’re  
asking for just a single record (Model.find(:first) or Model.find  
(:last)) you simply get the record/model back.

–  
Best regards,  
David K.  
[http://twitter.com/rubyguy](http://twitter.com/rubyguy)

---

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [April 12, 2009, 9:44pm UTC](https://www.ruby-forum.com/t/rss-feed-parsing-problem/165341/3 "2009-04-12T21:44:33Z")

</div>

hi thanks for the reply, was much needed.

I knew what i was trying to do which was like you say call each of the  
items in the array i just wasnt sure how to do it, and attempted a  
similar type of loop but had no luck.

I will look into this and see if i can achieve what i want

Thanks alot

nick

---

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [April 12, 2009, 10:02pm UTC](https://www.ruby-forum.com/t/rss-feed-parsing-problem/165341/4 "2009-04-12T22:02:50Z")

</div>

Nick H. wrote:

> hi thanks for the reply, was much needed.
> 
> I knew what i was trying to do which was like you say call each of the  
> items in the array i just wasnt sure how to do it, and attempted a  
> similar type of loop but had no luck.
> 
> I will look into this and see if i can achieve what i want
> 
> Thanks alot
> 
> nick

just another quick question

how would i able to output each parsed feed from the array @feeds[] in a  
view?

---

<div class="post-metadata">

**Author:** ![nickh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7ea924/32.png) [@nickh](https://www.ruby-forum.com/u/nickh)\
**Post date:** [April 15, 2009, 9:04pm UTC](https://www.ruby-forum.com/t/rss-feed-parsing-problem/165341/5 "2009-04-15T21:04:34Z")

</div>

On 12 Apr., 22:02, Nick H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> > nick
> 
> just another quick question
> 
> how would i able to output each parsed feed from the array @feeds[] in a  
> view?

You would do something like this:

 \<%- @feeds.each do |feed| -%\> - \<%= feed.channel.title %\>
 \<%- end -%\>

Voila, a list of feed titles. 🙂

–  
Best regards,  
David K.  
[http://twitter.com/rubyguy](http://twitter.com/rubyguy)
