# Gem install activerecord--adapter

**URL:** <https://rubytalk.org/t/gem-install-activerecord-adapter/55593>\
**Category:** ruby-talk\
**Created:** [29 September 2009 14:38 UTC](https://rubytalk.org/t/gem-install-activerecord-adapter/55593 "2009-09-29T14:38:28Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thufir](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@Thufir](https://rubytalk.org/u/Thufir)\
**Post date:** [29 September 2009 14:38 UTC](https://rubytalk.org/t/gem-install-activerecord-adapter/55593/1 "2009-09-29T14:38:28Z")

</div>

I seem to be missing a gem, yet, according to gem list, I seem to have  
sufficient gems. It's a bit puzzling in that this script was running and  
now just throws this error.

Is this a missing gem? If so, which one? The MySQL gem seems to be  
installed.

thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ ruby 5.rb  
/var/lib/gems/1.8/gems/activerecord-2.3.4/lib/active\_record/  
connection\_adapters/abstract/connection\_specification.rb:76:in  
`establish_connection': Please install the adapter: `gem install  
activerecord--adapter` (no such file to load -- active\_record/  
connection\_adapters/\_adapter) (RuntimeError)  
&nbsp;&nbsp;from 5.rb:7  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ gem list

\*\*\* LOCAL GEMS \*\*\*

actionmailer (2.3.4)  
actionpack (2.3.4)  
activerecord (2.3.4)  
activeresource (2.3.4)  
activesupport (2.3.4)  
builder (2.1.2)  
columnize (0.3.1)  
composite\_primary\_keys (2.3.2)  
feedtools (0.2.29)  
mysql (2.8.1)  
rack (1.0.0)  
rails (2.3.4)  
rake (0.8.7)  
rdoc (2.4.3)  
rogerdpack-rbeautify (0.0.6)  
uuidtools (2.0.0)  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ nl 5.rb  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 require 'rubygems'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 require 'active\_record'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 require 'feed\_tools'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4 require 'yaml'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5 db = YAML.load\_file("database.yml")  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6 ActiveRecord::Base.establish\_connection(  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7 :adapter =\> db["adapter"],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8 :host =\> db["host"],  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;9 :username =\> db["username"],  
&nbsp;&nbsp;&nbsp;&nbsp;10 :password =\> db["password"],  
&nbsp;&nbsp;&nbsp;&nbsp;11 :database =\> db["database"])  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;12 class Items \< ActiveRecord::Base  
&nbsp;&nbsp;&nbsp;&nbsp;13 end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;14 # If the table doesn't exist, we'll create it.  
&nbsp;&nbsp;&nbsp;&nbsp;15 unless Items.table\_exists?  
&nbsp;&nbsp;&nbsp;&nbsp;16 ActiveRecord::Schema.define do  
&nbsp;&nbsp;&nbsp;&nbsp;17 create\_table :items do |t|  
&nbsp;&nbsp;&nbsp;&nbsp;18 t.column :title, :string  
&nbsp;&nbsp;&nbsp;&nbsp;19 t.column :content, :string  
&nbsp;&nbsp;&nbsp;&nbsp;20 t.column :source, :string  
&nbsp;&nbsp;&nbsp;&nbsp;21 t.column :url, :string  
&nbsp;&nbsp;&nbsp;&nbsp;22 t.column :timestamp, :timestamp  
&nbsp;&nbsp;&nbsp;&nbsp;23 t.column :keyword\_id, :integer  
&nbsp;&nbsp;&nbsp;&nbsp;24 t.column :guid, :string  
&nbsp;&nbsp;&nbsp;&nbsp;25 t.column :html, :string  
&nbsp;&nbsp;&nbsp;&nbsp;26 end  
&nbsp;&nbsp;&nbsp;&nbsp;27 end  
&nbsp;&nbsp;&nbsp;&nbsp;28 end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;29 feed\_url = '[http://www.slashdot.org/index.rss](http://www.slashdot.org/index.rss)'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;30 feed=FeedTools::Feed.open(feed\_url)  
&nbsp;&nbsp;&nbsp;&nbsp;31 feed.items.each do |feed\_item|  
&nbsp;&nbsp;&nbsp;&nbsp;32 unless (Items.find\_by\_title(feed\_item.title) \  
&nbsp;&nbsp;&nbsp;&nbsp;33 or Items.find\_by\_url(feed\_item.link) \  
&nbsp;&nbsp;&nbsp;&nbsp;34 or Items.find\_by\_guid(feed\_item.guid))  
&nbsp;&nbsp;&nbsp;&nbsp;35 puts "processing item '#{feed\_item.title}' - new"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;36 Items.new do |newitem|  
&nbsp;&nbsp;&nbsp;&nbsp;37 newitem.title=feed\_item.title.gsub(/\<[^\>]\*\>/, '')  
&nbsp;&nbsp;&nbsp;&nbsp;38 newitem.guid=feed\_item.guid  
&nbsp;&nbsp;&nbsp;&nbsp;39 if feed\_item.publisher.name  
&nbsp;&nbsp;&nbsp;&nbsp;40 newitem.source=feed\_item.publisher.name  
&nbsp;&nbsp;&nbsp;&nbsp;41 end  
&nbsp;&nbsp;&nbsp;&nbsp;42 newitem.url=feed\_item.link  
&nbsp;&nbsp;&nbsp;&nbsp;43 newitem.content=feed\_item.description  
&nbsp;&nbsp;&nbsp;&nbsp;44 newitem.timestamp=feed\_item.published  
&nbsp;&nbsp;&nbsp;&nbsp;45 newitem.save  
&nbsp;&nbsp;&nbsp;&nbsp;46 end  
&nbsp;&nbsp;&nbsp;&nbsp;47 else  
&nbsp;&nbsp;&nbsp;&nbsp;48 puts "processing item '#{feed\_item.title}' - old"  
&nbsp;&nbsp;&nbsp;&nbsp;49 end  
&nbsp;&nbsp;&nbsp;&nbsp;50 end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ cat /etc/lsb-release  
DISTRIB\_ID=Ubuntu  
DISTRIB\_RELEASE=9.04  
DISTRIB\_CODENAME=jaunty  
DISTRIB\_DESCRIPTION="Ubuntu 9.04"  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ ruby -v  
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]  
thufir@ARRAKIS:~/projects/rss$

thanks,

Thufir

---

<div class="post-metadata">

**Author:** ![Charles\_Johnson](https://avatars.discourse-cdn.com/v4/letter/c/f475e1/32.png) [@Charles\_Johnson](https://rubytalk.org/u/Charles_Johnson)\
**Post date:** [29 September 2009 14:44 UTC](https://rubytalk.org/t/gem-install-activerecord-adapter/55593/2 "2009-09-29T14:44:44Z")

</div>

Did you intend something like this (just a guess)

:adapter =\> db["mysql"]

Cheers--

Charles

> **···**
>
> On Sep 29, 2009, at 9:38 AM, Thufir wrote:
> 
> > I seem to be missing a gem, yet, according to gem list, I seem to have  
> > sufficient gems. It's a bit puzzling in that this script was running and  
> > now just throws this error.
> > 
> > thufir@ARRAKIS:~/projects/rss$ nl 5.rb  
> > &nbsp;&nbsp;&nbsp;&nbsp;1 require 'rubygems'  
> > &nbsp;&nbsp;&nbsp;&nbsp;2 require 'active\_record'  
> > &nbsp;&nbsp;&nbsp;&nbsp;3 require 'feed\_tools'  
> > &nbsp;&nbsp;&nbsp;&nbsp;4 require 'yaml'
> > 
> > &nbsp;&nbsp;&nbsp;&nbsp;5 db = YAML.load\_file("database.yml")  
> > &nbsp;&nbsp;&nbsp;&nbsp;6 ActiveRecord::Base.establish\_connection(  
> > &nbsp;&nbsp;&nbsp;&nbsp;7 :adapter =\> db["adapter"],  
> > &nbsp;&nbsp;&nbsp;&nbsp;8 :host =\> db["host"],  
> > &nbsp;&nbsp;&nbsp;&nbsp;9 :username =\> db["username"],  
> > &nbsp;&nbsp;&nbsp;10 :password =\> db["password"],  
> > &nbsp;&nbsp;&nbsp;11 :database =\> db["database"])
> 
> --  
> Charles Johnson  
> Advanced Computing Center for Research and Education  
> Vanderbilt University

---

<div class="post-metadata">

**Author:** ![Aldric\_Giacomoni2](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@Aldric\_Giacomoni2](https://rubytalk.org/u/Aldric_Giacomoni2)\
**Post date:** [29 September 2009 17:18 UTC](https://rubytalk.org/t/gem-install-activerecord-adapter/55593/3 "2009-09-29T17:18:04Z")

</div>

1) require 'activerecord' ... Why do you have this underscore in there?  
2) Try :adapter =\> db[:adapter] instead ?

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Thufir](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@Thufir](https://rubytalk.org/u/Thufir)\
**Post date:** [30 September 2009 13:19 UTC](https://rubytalk.org/t/gem-install-activerecord-adapter/55593/4 "2009-09-30T13:19:32Z")

</div>

> 1) require 'activerecord' ... Why do you have this underscore in there?  
> 2) Try :adapter =\> db[:adapter] instead ?

I only briefly googled it, once I knew it wasn't a gems problem, and came  
up with:

thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ ruby 9.rb  
mysql  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ nl 9.rb  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 require 'rubygems'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 require 'activerecord'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 require 'feed\_tools'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4 require 'yaml'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5 #db = YAML.load\_file("database.yml") #how is this different  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6 dbconfig = YAML::load(File.open('database.yml'))  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7 foo = (dbconfig["development"]["adapter"])  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8 puts foo  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$ nl database.yml  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1 development:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2 adapter: mysql  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3 # adapter: sqlite3  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4 host: 127.0.0.1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5 database: rss2mysql  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6 username: ruby  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;7 password: password #err, don't steal my "secret" password  
thufir@ARRAKIS:~/projects/rss$  
thufir@ARRAKIS:~/projects/rss$

So, I'm mostly "there", I'm just a bit unfamiliar with the ?hash? symbol,  
=\>, as well as the :symbol syntax.

Thanks for pointing me in the right direction!

-Thufir

> **···**
>
> On Wed, 30 Sep 2009 02:18:04 +0900, Aldric Giacomoni wrote:  
> from ::load ?
