Forum: Ruby on Rails Rails and Postgres

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6967418e1ae7f0aaa64a6689a401d9dd?d=identicon&s=25 Craig Mcdonnell (craigmcdonnell)
on 2006-05-22 01:40
Hi, I'm new to Ruby on Rails and am having a little difficulty working
through the 'Rolling with Ruby on Rails' tutorial. Can anyone help?

I'm trying to get the cookbook application to work via a Postgresql db.
But get the following error when trying to access
http://127.0.0.1:3000/recipe/new

Errno::EINVAL in RecipeController#new
Invalid argument
RAILS_ROOT: ./script/../config/..

I'm using Ruby version ruby182-15.exe (Windows XP Home) running
Postgresql version 8.1

Here's the console output:

C:\InstantRails\rails_apps\cookbook>ruby script/server
=> Booting WEBrick...
=> Rails application started on http://0.0.0.0:3000
=> Ctrl-C to shutdown server; call with --help for options
[2006-05-22 00:32:20] INFO WEBrick 1.3.1
[2006-05-22 00:32:20] INFO ruby 1.8.2 (2004-12-25) [i386-mswin32]
[2006-05-22 00:32:20] INFO WEBrick::HTTPServer#start: pid=2684 port=3000
127.0.0.1 - - [22/May/2006:00:32:26 GMT Standard Time] "GET /recipe/new
HTTP/1.1
" 500 12418
- -> /recipe/new

Any ideas as to what I'm doing wrong? Thanks for any help... Sorry if
this is a total newbie question!!
F3dc06f587d1ff4c7366b102bfda9204?d=identicon&s=25 David Mitchell (Guest)
on 2006-05-22 01:52
(Received via mailing list)
Craig,

I worked through this tutorial with Postgres many months ago; I know
it works with Postgres, but the fine details of any tweaks I applied
aren't exactly fresh in my mind.

That said, my guess is that you've got an error in your view or
controller, rather than some sort of Postgres issue.  Check for any
typos; if you can't find any, then post the full stack trace of your
error message which will probably give a better indication about where
things went off the <groan> rails </groan>.

Regards

Dave M.
6967418e1ae7f0aaa64a6689a401d9dd?d=identicon&s=25 Craig Mcdonnell (craigmcdonnell)
on 2006-05-22 02:01
Wow! Thanks for the quick response David.

Here are the details.

recipe_controller.rb:

class RecipeController < ApplicationController
    scaffold :recipe
end

Full trace is:
c:/ruby/lib/ruby/1.8/readbytes.rb:16:in `read'
c:/ruby/lib/ruby/1.8/readbytes.rb:16:in `readbytes'
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/message.rb:32:in
`read'
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:30:in
`initialize'
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:29:in
`loop'
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/connection.rb:29:in
`initialize'
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:23:in
`new'
c:/ruby/lib/ruby/gems/1.8/gems/postgres-pr-0.4.0/lib/postgres-pr/postgres-compat.rb:23:in
`initialize'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/postgresql_adapter.rb:24:in
`connect'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/postgresql_adapter.rb:24:in
`postgresql_connection'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:251:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:251:in
`connection_without_query_cache='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/query_cache.rb:54:in
`connection='
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:220:in
`retrieve_connection'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:78:in
`connection'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:696:in
`columns'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1969:in
`attributes_from_column_definition'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/base.rb:1351:in
`initialize_without_callbacks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/callbacks.rb:236:in
`initialize'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/scaffolding.rb:124:in
`new'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/scaffolding.rb:124:in
`new'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:910:in
`perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:368:in
`perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/benchmarking.rb:69:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/rescue.rb:82:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/base.rb:381:in
`process_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/filters.rb:377:in
`process_without_session_management_support'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/session_management.rb:117:in
`process'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/dispatcher.rb:38:in
`dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:115:in
`handle_dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:81:in
`service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'
c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'
c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'
c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/webrick_server.rb:67:in
`dispatch'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/servers/webrick.rb:59
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.2/lib/commands/server.rb:30
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require__'
c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in
`require'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in
`require'
script/server:3

And session dump is:
---
flash: !ruby/hash:ActionController::Flash::FlashHash {}
753528fbc8b89d5f3bbcd5558c36d168?d=identicon&s=25 Glenn Cadman (glenn)
on 2006-05-22 03:34
I just did the tutorial with postgres (I like Postgres as it is a ACID
complaint DB), it worked find.

Can you post the code of your controller I may be able to do a quick
comparison check.

Some strange errors messages occur with rails.
6967418e1ae7f0aaa64a6689a401d9dd?d=identicon&s=25 Craig Mcdonnell (craigmcdonnell)
on 2006-05-22 11:49
Sure:

class RecipeController < ApplicationController
    scaffold :recipe
end

Could you perhaps describe which versions of each file you were using?
And which/how you installed the postgres interpreter? Maybe I'm using
incompatible versions.

Thanks for your help.
6967418e1ae7f0aaa64a6689a401d9dd?d=identicon&s=25 Craig Mcdonnell (craigmcdonnell)
on 2006-05-22 18:27
Also, does it matter which encoding is used for the postgresql db?
4ba4bb954bcfec077d9708b540558926?d=identicon&s=25 Guido Sohne (Guest)
on 2006-05-22 21:40
(Received via mailing list)
I doubt that matters. From your backtrace it is having trouble
connecting to the database at initialization time, do you have a
firewall or something like that ...

Here's a stanza from my database.yml ...

development:
   adapter: postgresql
   database: rosebank_development
   username: guido
   password:
   encoding: UTF8
   host: localhost
   port: 5444

What does your database.yml say?

If the problem persists, you may want to try using the Unix sockets
to connect instead ..

-- G.
B84d42a3a5c343f8fc6ab7d7f47fd3f5?d=identicon&s=25 Robby Russell (Guest)
on 2006-05-23 01:42
(Received via mailing list)
On May 22, 2006, at 9:27 AM, Craig McDonnell wrote:

> Also, does it matter which encoding is used for the postgresql db?

it depends on the encoding requirements of your application. :-)

..but for any generic Rails application... no...

You might try the postgres adapter not the postgres-pr one.

Robby

--
Robby Russell
Founder & Executive Director

PLANET ARGON, LLC
Ruby on Rails Development, Consulting & Hosting

www.planetargon.com
www.robbyonrails.com

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4968 [fax]
820d0e4ee14e986a44d33782ca852f51?d=identicon&s=25 bob (Guest)
on 2006-05-23 01:52
this is my first post
This topic is locked and can not be replied to.