Rails 3-默认情况下不会在控制器上加载索引操作 [英] Rails 3 - index action not loading by default on controller
本文介绍了Rails 3-默认情况下不会在控制器上加载索引操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
现在我有一个全新的 rails 3
安装,运行在 rvm 1.9.2
上,我生成了一个控制器使用以下指令:
Now i have a fresh rails 3
install running over rvm 1.9.2
I generated a controller using the follow instruction:
rails generate controller blog index
输出为
create app/controllers/blog_controller.rb
route get "blog/index"
invoke erb
create app/views/blog
create app/views/blog/index.html.erb
invoke test_unit
create test/functional/blog_controller_test.rb
invoke helper
create app/helpers/blog_helper.rb
invoke test_unit
create test/unit/helpers/blog_helper_test.rb
但是在浏览器中,当我尝试访问 http:// localhost:3000 /博客
我得到:
but in browser when i try to get to http://localhost:3000/blog
i get:
No route matches "/blog"
但是如果我键入 http:// localhost:3000 / blog / index
它呈现索引视图。
它不像Rails 2一样工作吗?在默认情况下,我只需将控制器名称放在url上即可进入索引视图?
doesn't it works like Rails 2? where i get to the index view by default with just putting the controller name on the url ?
谢谢。
推荐答案
对于Rails 3:
match '/blog', :controller => 'blog', :action => 'index'
这篇关于Rails 3-默认情况下不会在控制器上加载索引操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文