gem install activerecord--adapter

  • Follow


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)
	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 
     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
       
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


0
Reply hawat.thufir (2520) 9/29/2009 2:38:28 PM

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
>     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"])
Did you intend something like this (just a guess)

:adapter => db["mysql"]

Cheers--

Charles
--
Charles Johnson
Advanced Computing Center for Research and Education
Vanderbilt University




0
Reply charles.johnson (30) 9/29/2009 2:44:44 PM


1) require 'activerecord' ... Why do you have this underscore in there?
2) Try :adapter => db[:adapter] instead ?
-- 
Posted via http://www.ruby-forum.com/.

0
Reply aldric (174) 9/29/2009 5:18:04 PM

On Wed, 30 Sep 2009 02:18:04 +0900, Aldric Giacomoni 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:

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 
     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
thufir@ARRAKIS:~/projects/rss$ 
thufir@ARRAKIS:~/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
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


0
Reply hawat.thufir (2520) 9/30/2009 1:19:32 PM

3 Replies
35 Views

(page loaded in 0.09 seconds)

Similiar Articles:




7/12/2012 3:38:51 PM


Reply: