Gem install activerecord--adapter

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.

[email protected]:~/projects/rss$
[email protected]:~/projects/rss$
[email protected]:~/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)
from 5.rb:7
[email protected]:~/projects/rss$
[email protected]:~/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)
[email protected]:~/projects/rss$
[email protected]:~/projects/rss$ nl 5.rb
1 require ‘rubygems’
2 require ‘active_record’
3 require ‘feed_tools’
4 require ‘yaml’

 5  db = YAML.load_file("database.yml")
 6  ActiveRecord::Base.establish_connection(
 7  :adapter  => db["adapter"],
 8  :host   => db["host"],
 9  :username => db["username"],
10  :password => db["password"],
11  :database => db["database"])

12  class Items <  ActiveRecord::Base
13  end

14  # If the table doesn't exist, we'll create it.
15  unless Items.table_exists?
16    ActiveRecord::Schema.define do
17      create_table :items do |t|
18        t.column :title, :string
19        t.column :content, :string
20        t.column :source, :string
21        t.column :url, :string
22        t.column :timestamp, :timestamp
23        t.column :keyword_id, :integer
24        t.column :guid, :string
25        t.column :html, :string
26      end
27    end
28  end

29  feed_url = 'http://www.slashdot.org/index.rss'

30  feed=FeedTools::Feed.open(feed_url)
31  feed.items.each do |feed_item|
32    unless (Items.find_by_title(feed_item.title) \
33    or Items.find_by_url(feed_item.link) \
34    or Items.find_by_guid(feed_item.guid))
35      puts "processing item '#{feed_item.title}' - new"

36      Items.new do |newitem|
37        newitem.title=feed_item.title.gsub(/<[^>]*>/, '')
38        newitem.guid=feed_item.guid
39        if feed_item.publisher.name
40          newitem.source=feed_item.publisher.name
41        end
42        newitem.url=feed_item.link
43        newitem.content=feed_item.description
44        newitem.timestamp=feed_item.published
45        newitem.save
46      end
47    else
48      puts "processing item '#{feed_item.title}' - old"
49    end
50  end

[email protected]:~/projects/rss$
[email protected]:~/projects/rss$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.04
DISTRIB_CODENAME=jaunty
DISTRIB_DESCRIPTION=“Ubuntu 9.04”
[email protected]:~/projects/rss$
[email protected]:~/projects/rss$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]
[email protected]:~/projects/rss$

thanks,

Thufir

On Sep 29, 2009, at 9:38 AM, Thufir wrote:

5  db = YAML.load_file("database.yml")
6  ActiveRecord::Base.establish_connection(
7  :adapter  => db["adapter"],
8  :host   => db["host"],
9  :username => db["username"],

10 :password => db[“password”],
11 :database => db[“database”])
Did you intend something like this (just a guess)

:adapter => db[“mysql”]

Cheers–

Charles

  1. require ‘activerecord’ … Why do you have this underscore in there?
  2. Try :adapter => db[:adapter] instead ?

On Wed, 30 Sep 2009 02:18:04 +0900, Aldric G. wrote:

  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:

[email protected]:~/projects/rss$
[email protected]:~/projects/rss$
[email protected]:~/projects/rss$ ruby 9.rb
mysql
[email protected]:~/projects/rss$
[email protected]:~/projects/rss$ nl 9.rb
1 require ‘rubygems’
2 require ‘activerecord’
3 require ‘feed_tools’
4 require ‘yaml’

 5   #db = YAML.load_file("database.yml")  #how is this different

from ::load ?

 6   dbconfig = YAML::load(File.open('database.yml'))
 7   foo = (dbconfig["development"]["adapter"])


 8  puts foo

[email protected]:~/projects/rss$
[email protected]:~/projects/rss$ nl database.yml
1 development:
2 adapter: mysql
3 # adapter: sqlite3
4 host: 127.0.0.1
5 database: rss2mysql
6 username: ruby
7 password: password #err, don’t steal my “secret” password
[email protected]:~/projects/rss$
[email protected]:~/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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs