[英]Hartls Tutorial Section 3.4 rails generate controller error
I'm following Hartl's rails tutorial and when issue the following command: 我正在关注Hartl的rails教程,并在发出以下命令时:
rails generate controller StaticPages home help --no-test-framework Rails生成控制器StaticPages主页帮助--no-test-framework
it throws and error: 它抛出错误:
You should not use the match
method in your router without specifying an HTTP method. 如果未指定HTTP方法,则不应在路由器中使用
match
方法。 (RuntimeError) If you want to expose your action to both GET and POST, add via: [:get, :post]
option. (RuntimeError)如果要同时对GET和POST公开操作,请
via: [:get, :post]
选项添加。 If you want to expose your action to GET, use get
in the router: Instead of: match "controller#action" Do: get "controller#action" 如果要将操作公开给GET,请在路由器中使用
get
:而不是:match“ controller#action”执行:get“ controller#action”
I am using Rails 2.1.0 and I'm wondering if that is creating the problem? 我正在使用Rails 2.1.0,我想知道这是否是造成问题的原因? Do I need to change some of the syntax in the route.rb file?
我是否需要更改route.rb文件中的某些语法?
You should be having a route in routes.rb
for which you have not specified HTTP method. 您应该在
routes.rb
中有一条尚未指定HTTP方法的路由。
For example: For a PhotosController
with show
action, use: 例如:对于具有
show
操作的PhotosController
,请使用:
match 'photos', to: 'photos#show', via: [:get, :post]
I would also suggest you to use latest version of Rails 4.x , if you are just doing the Rails Tutorial. 如果您只是在做Rails教程,我也建议您使用最新版本的Rails4.x 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.