Brand new to rails: can't get databases to work

Just starting to learn rails. All is going well, until I tried to hook
up a database.

“undefined method `model’ for ZingerController:Class” is the message I
get from the server.

I imagine I’ve left something out that is keeping me from connecting
to the database, but I’m not exactly sure what.

Your help is appreciated.

bests,

-rsr-

session dump:

flash: !map:ActionController::Flash::FlashHash {}

database.yml file:

SQLite version 3.x

gem install mysql-ruby (not necessary on OS X Leopard)

development:
adapter: mysql
database: db/zingers
timeout: 5000

Warning: The database defined as ‘test’ will be erased and

re-generated from your development database when you run ‘rake’.

Do not set this db to the same as development or production.

test:
adapter: mysqlsqlite3
database: db/test.sqlite3
timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
timeout: 5000

and log:

Processing ZingerController#index (for 127.0.0.1 at 2008-04-13
01:10:36) [GET]
Session ID:
BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo
%0ASGFzaHsABjoKQHVzZWR7AA%3D%3D–
ef1274263edd272a9339dc3c133cce94df9dc83e
Parameters: {“action”=>“index”, “controller”=>“zinger”}

ArgumentError (No database specified. Missing argument: database.):
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/mysql_adapter.rb:81:in
mysql_connection' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/connection_adapters/abstract/connection_specification.rb: 291:insend’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
291:in connection=' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/connection_adapters/abstract/connection_specification.rb: 259:inretrieve_connection’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/
active_record/connection_adapters/abstract/connection_specification.rb:
78:in connection' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/ active_record/query_cache.rb:8:incache’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/caching.rb:677:in perform_action' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:524:insend’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/base.rb:524:in process_without_filters' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/filters.rb:685:inprocess_without_session_management_support’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/session_management.rb:123:in process' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/base.rb:388:inprocess’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/dispatcher.rb:171:in handle_request' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:115:indispatch’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/
action_controller/dispatcher.rb:126:in dispatch_cgi' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/ action_controller/dispatcher.rb:9:indispatch’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/bin/…/lib/mongrel/rails.rb:76:in process' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/bin/../lib/mongrel/rails.rb:74:insynchronize’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/bin/…/lib/mongrel/rails.rb:74:in process' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel.rb:159:inprocess_client’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/lib/mongrel.rb:158:in each' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel.rb:158:inprocess_client’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/lib/mongrel.rb:285:in run' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel.rb:285:ininitialize’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/lib/mongrel.rb:285:in new' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel.rb:285:inrun’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/lib/mongrel.rb:268:in initialize' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel.rb:268:innew’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/lib/mongrel.rb:268:in run' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel/configurator.rb:282:inrun’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/lib/mongrel/configurator.rb:281:in each' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel/configurator.rb:281:inrun’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/bin/mongrel_rails:128:in run' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86- mswin32/lib/mongrel/command.rb:212:inrun’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/mongrel-1.1.2-x86-
mswin32/bin/mongrel_rails:281
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/
lib/active_support/dependencies.rb:489:in load' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:489:inload’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/
lib/active_support/dependencies.rb:342:in new_constants_in' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:489:inload’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
commands/servers/mongrel.rb:64
C:/instantrails/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in gem_original_require' C:/instantrails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:inrequire’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/
lib/active_support/dependencies.rb:496:in require' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/ lib/active_support/dependencies.rb:342:innew_constants_in’
C:/instantrails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/
lib/active_support/dependencies.rb:496:in require' C:/instantrails/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/ commands/server.rb:39 C:/instantrails/ruby/lib/ruby/site_ruby/1.8/rubygems/ custom_require.rb:27:ingem_original_require’
C:/instantrails/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:27:in `require’
script/server:3

Rendering C:/instantrails/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/
lib/action_controller/templates/rescues/layout.erb
(internal_server_error)

On 13 Apr 2008, at 06:24, ronrsr wrote:

SQLite version 3.x

gem install mysql-ruby (not necessary on OS X Leopard)

development:
adapter: mysql
database: db/zingers
timeout: 5000

this should be just

development:
adapter: mysql
database: zingers
username:
password:
host: localhost

(obviously stick the desired username and password in there)

Fred

Thanks - that helped a bit — now I get a different error:

Unknown database: zinger

the database is named zingers_development and is on 127.0.0.1 (not
port 3000) on mysql server.

it has no password.

iT seems I am looking in the wrong place for the db.

I would again appreciate any help.

bests,

-rsr-

On Apr 13, 7:00 am, Frederick C. [email protected]

This may help, too:

error message in log (the first one):

ActionController::RoutingError (No route matches “/mysql” with
( :method=>:get))

bests,

=-rsr=

On Apr 13, 2008, at 2:44 PM, ronrsr wrote:

Unknown database: zinger
the database is named zingers_development

If that’s the name of the database then that’s what you have to put in
the database: line.

did that, still, it’s “database not found.”

here’s the latest trace:

c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
vendor/mysql.rb:523:in read' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ vendor/mysql.rb:153:inreal_connect’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/mysql_adapter.rb:471:in connect' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/mysql_adapter.rb:165:ininitialize’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/mysql_adapter.rb:88:in new' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/mysql_adapter.rb:88:inmysql_connection’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/connection_specification.rb:291:in send' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract/connection_specification.rb:291:inconnection=’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
connection_adapters/abstract/connection_specification.rb:259:in
retrieve_connection' c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/ connection_adapters/abstract/connection_specification.rb:78:inconnection’
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/
query_cache.rb:8:in cache' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ caching.rb:677:inperform_action’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:524:in send' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ base.rb:524:inprocess_without_filters’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
filters.rb:685:in process_without_session_management_support' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ session_management.rb:123:inprocess’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
base.rb:388:in process' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:171:inhandle_request’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:115:in dispatch' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/ dispatcher.rb:126:indispatch_cgi’
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.0.2/lib/action_controller/
dispatcher.rb:9:in dispatch' c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb: 112:inhandle_dispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:78:in
service' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:inservice’
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in run' c:/ruby/lib/ruby/1.8/webrick/server.rb:173:instart_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:162:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:162:instart_thread’
c:/ruby/lib/ruby/1.8/webrick/server.rb:95:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:92:ineach’
c:/ruby/lib/ruby/1.8/webrick/server.rb:92:in start' c:/ruby/lib/ruby/1.8/webrick/server.rb:23:instart’
c:/ruby/lib/ruby/1.8/webrick/server.rb:82:in start' c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/webrick_server.rb:62:indispatch’
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/servers/
webrick.rb:66
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
gem_original_require' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:inrequire’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in require' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/ dependencies.rb:342:innew_constants_in’
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/
dependencies.rb:496:in require' c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:ingem_original_require’
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in
`require’
SCRIPT/SERVER:3

development:
adapter: mysql
database: db/zingers

You are using a mysql adapter and the database name is “sqlite-like”.
If you are just testing rails I suggest you to use sqlite3 database,
so you don’t have to mess with mysql database.
Just change your development adapter to sqlite3 and make sure the db
directory is writeable (because the database will be phisically
stored there).
Otherwise if you want to use mysql you have to create the database
(you can do that also with rake db:create) and you need to write in
the configuration file also the username and password of the db user.

you restarted your server?

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #4 coming soon!
http://sensei.zenunit.com/

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