Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
252 views
in Technique[技术] by (71.8m points)

ruby on rails - No Route matches "say/hello" when route exists

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"

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

With the details you've given I'm not sure why your route can't be found.

However, I believe the reason you're experiencing the no such file or directory error is because you're typing /app/views/say/hello.html.erb. Try removing the leading slash, so that it reads app/views/say/hello.html.erb. Bash appears to be parsing the former path as an absolute path, instead of a path relative to your current working directory.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...