# Undefined method for a gem?

**URL:** <https://www.ruby-forum.com/t/undefined-method-for-a-gem/175806>\
**Category:** Ruby\
**Created:** [September 20, 2009, 7:44am UTC](https://www.ruby-forum.com/t/undefined-method-for-a-gem/175806 "2009-09-20T07:44:48Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [September 20, 2009, 7:44am UTC](https://www.ruby-forum.com/t/undefined-method-for-a-gem/175806/1 "2009-09-20T07:44:48Z")

</div>

I’m thinking that the API for this gem has changed, hence the error?  
I’m  
looking into the documentation. Else, I’m not sure how to approach an  
undefined method.

I pulled the code from:

Practical Ruby Gems  
[http://www.apress.com/book/view/9781590598115](http://www.apress.com/book/view/9781590598115)

thufir@ARRAKIS:~/rb$  
thufir@ARRAKIS:~/rb$ ruby rss2mysql.rb  
/var/lib/gems/1.8/gems/feedtools-0.2.29/lib/feed\_tools/feed.rb:312:in  
`load_remote_feed!': undefined method `scheme’ for nil:NilClass  
(NoMethodError)  
from /var/lib/gems/1.8/gems/feedtools-0.2.29/lib/feed\_tools/  
feed.rb:202:in `update!' from /var/lib/gems/1.8/gems/feedtools-0.2.29/lib/feed_tools/ feed.rb:155:in `open’  
from rss2mysql.rb:32  
thufir@ARRAKIS:~/rb$  
thufir@ARRAKIS:~/rb$ cat rss2mysql.rb  
require ‘rubygems’  
require ‘active\_record’  
require ‘feed\_tools’

feed\_url = ARGV[0]

# This call creates a connection to our database.

ActiveRecord::Base.establish\_connection(  
:adapter =\> “mysql”,  
:host =\> “127.0.0.1”,  
:username =\> “ruby”, # Note that while this is the default setting for  
MySQL,  
:password =\> “password”, # a properly secured system will have a  
different MySQL  
# username and password, and if so, you’ll need to  
# change these settings.  
:database =\> “rss2mysql”)  
class Items \< ActiveRecord::Base  
end

# If the table doesn’t exist, we’ll create it.

unless Items.table\_exists?  
ActiveRecord::Schema.define do  
create\_table :items do |t|  
t.column :title, :string  
t.column :content, :string  
t.column :source, :string  
t.column :url, :string  
t.column :timestamp, :timestamp  
t.column :keyword\_id, :integer  
t.column :guid, :string  
end  
end  
end  
feed=FeedTools::Feed.open(feed\_url)  
feed.items.each do |feed\_item|  
if not (Items.find\_by\_title(feed\_item.title)   
or Items.find\_by\_url(feed\_item.link)   
or Items.find\_by\_guid(feed\_item.guid))  
puts “processing item ‘#{feed\_item.title}’ - new”

```
Items.new do |newitem|
   newitem.title=feed_item.title.gsub(/<[^>]*>/, '')
   newitem.guid=feed_item.guid
   if feed_item.publisher.name
       newitem.source=feed_item.publisher.name
   end
   newitem.url=feed_item.link
   newitem.content=feed_item.description
   newitem.timestamp=feed_item.published
   newitem.save
end

```

else  
puts “processing item ‘#{feed\_item.title}’ - old”  
end  
end

thufir@ARRAKIS:~/rb$

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Thufir](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ee7513/32.png) [@Thufir](https://www.ruby-forum.com/u/Thufir)\
**Post date:** [September 20, 2009, 8:29am UTC](https://www.ruby-forum.com/t/undefined-method-for-a-gem/175806/2 "2009-09-20T08:29:18Z")

</div>

GROUP gmane.comp.lang.ruby.general  
User-Agent: Pan/0.132 (Waxed in Black)

On Sun, 20 Sep 2009 14:40:14 +0900, Thufir wrote:

> I pulled the code from:
> 
> Practical Ruby Gems  
> [http://www.apress.com/book/view/9781590598115](http://www.apress.com/book/view/9781590598115)

Chapter 10, parsing feeds.

Ok, a bit silly – I forgot to pass a URL, so it seems to populate the  
db. I guess it was trying to send null values to the db?

-Thufir
