RoR DB Connection Troubles

software development

#1

I can access the public page of my rails app. But if I try to generate scaffolding (ruby script/generate scaffold Person Admin) I get:

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:80:in establish_connection': undefined methodsymbolize_keys’ for -2:Fixnum (NoMethodError)
from ./script/…/config/environment.rb:59
from script/generate:2:in `require’
from script/generate:2

If I run public/dispatch.fcgi I get a similar error:

/usr/lib/ruby/gems/1.8/gems/activerecord-1.11.1/lib/active_record/connection_adapters/abstract_adapter.rb:80:in establish_connection': undefined methodsymbolize_keys’ for -1:Fixnum (NoMethodError)
from ./public/…/config/environment.rb:59
from public/dispatch.fcgi:21:in `require’
from public/dispatch.fcgi:21

Any assitance would be GREATLY appreciated!


#2

This has been kind of disappointing. I know the guys at Dreamhost are working hard because of the power outage but I’ve had this problem since before then and have gotten no help from them. I guess I’ll go blow everything away and start over from scratch trying to get this rails app up and running but if it doesn’t happen then I’m going to have to get my money back and go elsewhere…my clients are only willing to wait so long.


#3

That’s too bad you’re having problems, but it seems like the RoR stuff here at Dreamhost is not 100% solid yet. Most of my hard to trackdown errors were solved when I just deleted my entire rails application space and started over again (maybe due to configuration problems).

If you’re going to run more than one Rails app, I’d run each one as a different user. Since Rails spawns off several dispatch.fcgi processes it’s easy to reach the max allowed processes per user (35) when running two or more rails sites and using SSH/SFTP. When you hit that limit, your Rails apps will suffer (and you’ll have trouble with SSH).


#4

By public page, do you mean the ‘you’ve put ruby on rails’ page? Or is it a page that you developed in Ruby that is backed by a database? From your post it sounds like you may not have a database set up, or it isn’t configured quite right.

Is you database.yml set correctly in your /config folder? There are 3 settings in there by default. If you haven’t changed your mode to development in your environment.rb then you’ll be running in Production mode. That may be part of it there - I wouldn’t be surprised if there were issues with generating scaffolding in production mode.

Active Record is trying to call symbolize_keys on a Fixnum, which doesn’t have that method. There is a bunch of error checking in the method, but they were never expecting a Fixnum. Something is getting passed in wrong. I’d scour the database.yml pretty carefully – I bet that or the mode you’re in is throwing you off. Maybe you defined a development database connection not realizing that apps run in production mode by default at DreamHost?

You can look at exactly where the error is coming from in the source code here:

http://dev.rubyonrails.com/file/trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

You’ll see there’s actually quite a bit of documentation near the method your looking for (establish_connection at the line spec = spec.symbolize_keys). This is one very nice thing in working with rails – it’s all right there. A little digging and you can find all the magic goodies.

And I have to ask… you do have a database set up, right?

Finally, I’d really suggest doing development on a local machine. It’s pretty easy to get things going on your own machine and then just upload when you’re ready to go into production. I’ve actually never tried to generate scaffolding on a DreamHost server.

hth,

-Tom Wilcoxen
convergent arts