Routing Error

Hi guys,

I’m experiencing an annoying problem that I’ve hit a brick wall on. Basically I’m going through the Prag.Programmers Rails book and have got to building the depot application. I’ve set up mySQL ok and rails is installed and happy. However after running:

ruby script/generate scaffold Product Admin

All I am getting returned is a Rotuing error claiming that it couldn’t recognise /Admin. I’ve done some Googling and found that this is a problem lots of people have had for numerous reasons - all of which I have tried on my install with no luck. I have ruby 1.8.4 on Ubuntu installed with Rails 1.1.6. I am running MySQL 5 (which I can connect to via mysql admin locally on port 3306). I have installed all the mySQL libraries and run

gem install mysql (and picked 2.7).

My database.yml is setup to run mysql as root (with a password) connecting to localhost.I have also restarted WEBBrick a few times, and verified that I am running the server in the right place. One thing I did notice that is currently unexplained is an error during the scaffold generation (File not found /tmp/mysqld.sock) - which I don’t think is a problem as I am trying to connect over TCP.

Does anyone have any ideas?

Yeah, I tried /admin too (along with a whole host of others in desperation). As far as I am aware my mysqld.sock is in /var/run/mysql somewhere (being Ubuntu Linux). Do I still need this even though I want to connect over TCP/IP? is it just a case of adding socket: /var/run… into the database.yml?

Neil

This is all I get:

Processing Base#index (for 127.0.0.1 at 2006-10-23 21:48:20) [GET] Session ID: 94945ea69c35bc6c335d70acf4a59310 Parameters: {}

ActionController::RoutingError (Recognition failed for “/Admin”):

/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:522:in `recognition_failed'
/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:512:in `recognize!'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service'

/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'

/usr/lib/ruby/1.8/webrick/server.rb:95:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:23:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start'

/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30
/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'
./script/server:3

Regards

Neil

Neil Middleton wrote:

This is all I get:

Processing Base#index (for 127.0.0.1 at 2006-10-23 21:48:20) [GET]   Session ID: 94945ea69c35bc6c335d70acf4a59310   Parameters: {}

I have the same problem coincidently running Ubuntu (Edgy) but with Postgresql.

Here's what I did. Install ruby via apt, install ruby gems and rails via instructions on rails site. Next I wrote a small test site by myself that worked fine but did not use the database or rails scaffolds (enter name, stuffs name in session and allows you to log out clearing session). I decided to go back to the PragProg book and started on chapter 6, installing the postgres gem.

Created and checked the database exists, that the user/password is correct, that the rails page at http://localhost:3000 works. The version info from that page is

Ruby version 1.8.4 (i486-linux) RubyGems version 0.9.0 Rails version 1.1.6 Active Record version 1.14.4 Action Pack version 1.12.5 Action Web Service version 1.1.6 Action Mailer version 1.2.5 Active Support version 1.3.1 Application root /projects/learning/rails/depot Environment development Database adapter postgresql

development:   adapter: postgresql   database: depot_development   username: depot_dev   password: *apassword*   host: localhost

"./script/generate scaffold Product Admin" produced

      exists app/controllers/       exists app/helpers/       exists app/views/admin       exists test/functional/   dependency model       exists app/models/       exists test/unit/       exists test/fixtures/    identical app/models/product.rb    identical test/unit/product_test.rb    identical test/fixtures/products.yml

Removing the directory and following all steps produces same output. This was in log/development.log

Processing Base#index (for 127.0.0.1 at 2006-11-22 19:46:16) [GET]   Session ID: 099574b2922c609fefef547a70f3b953   Parameters: {}

ActionController::RoutingError (Recognition failed for "/admin"):

/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:522:in `recognition_failed'

/usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/routing.rb:512:in `recognize!'     /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/dispatcher.rb:38:in `dispatch'

/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:115:in `handle_dispatch'     /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:81:in `service'     /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'     /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'     /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'     /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'     /usr/lib/ruby/1.8/webrick/server.rb:95:in `start'     /usr/lib/ruby/1.8/webrick/server.rb:92:in `start'     /usr/lib/ruby/1.8/webrick/server.rb:23:in `start'     /usr/lib/ruby/1.8/webrick/server.rb:82:in `start'     /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/webrick_server.rb:67:in `dispatch'

/usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/servers/webrick.rb:59     /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'     /usr/lib/ruby/gems/1.8/gems/rails-1.1.6/lib/commands/server.rb:30     /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'

/usr/lib/ruby/gems/1.8/gems/activesupport-1.3.1/lib/active_support/dependencies.rb:147:in `require'     ./script/server:3

Rendering /usr/lib/ruby/gems/1.8/gems/actionpack-1.12.5/lib/action_controller/templates/rescues/layout.rhtml (404 Page Not Found)

Any ideas? The prag prog book suggests more files should be generated but are not. app/view/admin is completely empty.

Cheers, Chris

I just tried this with mysql and had no problems... sigh. Any ideas why it won't work with postgresql? Is there any way to trace db access when a scaffold is generated?

Cheers, Chris

After removing the native postgres gem then installing the postgres-pr driver gem instead it works fine.