0

I'm trying to create a very simple Hello, world program in RoR, but when I go to view the url http://localhost:3000/say/hello I'm getting the error message No route matches: "say/hello"

When I started the rails server I got this message with warnings scattered throughout:

=> Booting WEBrick
=> Rails 3.0.9 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2011-06-20 20:02:44] INFO  WEBrick 1.3.1
[2011-06-20 20:02:44] INFO  ruby 1.9.2 (2011-02-18) [i686-linux]
[2011-06-20 20:02:44] WARN  TCPServer Error: Address already in use - bind(2)
Exiting
/home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in `initialize': Address already in use - bind(2) (Errno::EADDRINUSE)
  from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in `new'
  from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in `block in create_listeners'
  from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:in `each'
  from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:in `create_listeners'
  from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:74:in `listen'
  from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:62:in `initialize'
  from /home/eyedea/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:24:in `initialize'
  from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/handler/webrick.rb:10:in `new'
  from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/handler/webrick.rb:10:in `run'
  from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.3/lib/rack/server.rb:217:in `start'
  from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands/server.rb:65:in `start'
  from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:30:in `block in <top (required)>'
  from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:27:in `tap'
  from /home/eyedea/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.9/lib/rails/commands.rb:27:in `<top (required)>'
  from script/rails:6:in `require'
  from script/rails:6:in `<main>'

I started with: rails generate controller Say hello goodbye which lists route get "say/hello"

Also: I'm having this problem which is probably related. When I go to write some basic html in one of the files that is clearly listed as existing I get this:

I write this:

~/work/demo$ /app/views/say/hello.html.erb

Get this error message in return:

bash: /app/views/say/hello.html.erb: No such file or directory

What's going on here? I'm getting these instructions straight from Agile Development with Rails and it's so simple. I don't understand what's going on.

nowk
  • 32,822
  • 2
  • 35
  • 40
Bodhidarma
  • 519
  • 1
  • 7
  • 25
  • 1
    possible duplicate of [No Route matches "say/hello" when route exists](http://stackoverflow.com/questions/6418549/no-route-matches-say-hello-when-route-exists) – Jesse Wolgamott Jun 21 '11 at 00:44

5 Answers5

1

The error you're getting at rails startup indicates that there is already a server running at port 3000 on your machine (and apparently that server knows nothing of a "say/hello" route). Shut that one down and try again.

KenB
  • 6,587
  • 2
  • 35
  • 31
1
[2011-06-20 20:02:44] WARN  TCPServer Error: Address already in use - bind(2)

You already have a server (or something) running on the port your server is supposed to be running on. As such, the code you think is running (which you say has the route in question) actually isn't running. Once you shut down the other process (probably a previously running rails server?), you can start the correct one and make sure it actually has that route.

RHSeeger
  • 16,034
  • 7
  • 51
  • 41
  • Googled the error message. Found instructions on how to kill the phantom server. Everything's working smoothly for now – Bodhidarma Jun 24 '11 at 23:35
0

The second error is because from bash the path / goes to the root directory. Try:

cat app/views/say/hello.html.erb
natedavisolds
  • 4,305
  • 1
  • 20
  • 25
0

I am faced with a similar problem. In my case after $ rails server command I am unable to shut down the server using ctrl-C in the terminal itself. Nothing happens when I press ctrl-C in the terminal.

When I reopen the project on another terminal, and run it again I get the following message:


System-Product-Name:~/testapp$ rails s => Booting WEBrick => Rails 3.1.0.rc4 application starting in development on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server [2011-06-30 16:41:23] INFO WEBrick 1.3.1 [2011-06-30 16:41:23] INFO ruby 1.9.2 (2011-02-18) [x86_64-linux] [2011-06-30 16:41:23] WARN TCPServer Error: Address already in use - bind(2) Exiting /.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in initialize': Address already in use - bind(2) (Errno::EADDRINUSE) ls.rb:73:innew' from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:73:in block in create_listeners' from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:ineach' from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/utils.rb:70:in create_listeners' from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:74:inlisten' from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:62:in initialize' from bubble/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:24:ininitialize' from bubble/.rvm/gems/ruby-1.9.2-p180@rails31/gems/rack-1.3.0/lib/rack/handler/webrick.rb:10:in new' from bubble/.rvm/gems/ruby-1.9.2-p180@rails31/gems/rack-1.3.0/lib/rack/handler/webrick.rb:10:inrun' from bubble/.rvm/gems/ruby-1.9.2-p180@rails31/gems/rack-1.3.0/lib/rack/server.rb:265:in start' from bubble/.rvm/gems/ruby-1.9.2-p180@rails31/gems/railties-3.1.0.rc4/lib/rails/commands/server.rb:70:instart' from bubble/.rvm/gems/ruby-1.9.2-p180@rails31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:54:in block in <top (required)>' from bubble/.rvm/gems/ruby-1.9.2-p180@rails31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:intap' from bubble/.rvm/gems/ruby-1.9.2-p180@rails31/gems/railties-3.1.0.rc4/lib/rails/commands.rb:49:in <top (required)>' from script/rails:6:inrequire' from script/rails:6:in `'


In essence I have to kill the process from system monitor everytime. Can this be cured?

Marvin Danig
  • 3,738
  • 6
  • 39
  • 71
  • What has worked for me is pressing Ctrl+z and then typing "fg" (Without the quotes, of course). This should kill the server. – bbonamin Jun 30 '11 at 12:27
  • What I want is not to kill the process every time. Rather fix the reason why the terminal is not accepting "Ctrl + C" hook to shutdown the server. Tried searching the web, but most talked about the kill switch. – Marvin Danig Jun 30 '11 at 14:50
  • 1
    From what I've found it's a Rails bug that has been present since around 3.0.5~. Here, some info http://stackoverflow.com/questions/5891567/cant-stop-webrick-1-3-1-with-ctrl-c-on-ubuntu-11-04 – bbonamin Jun 30 '11 at 22:22
0

On a mac, type the following in your terminal:

lsof | grep IPv4

or

lsof|grep 3000 in linux i think.

find the lione that starts with 'ruby' and note the number next to that.

let's say the number is 1234. type the following in you terminal:

kill -9 1234

and you should be right. Remember to exit out of WEBrick with control-c!

Ribena
  • 1,086
  • 1
  • 11
  • 20