2017-03-15 185 views
0

我已经做了控制,并得到以下错误消息路由错误的路由匹配[GET]

路由错误的路由匹配[获取]“handm /指数”

(这些是标题误差表

航路匹配优先从顶部到底部助手HTTP动词 路径控制器#动作路径/地址

(这是内容)handm_index_path GET /小时)和m /指数(:格式) handm#指数root_path GET/handm#指数请求参数:

可能有人解释这是什么错误意味着请。下面是我的路线文件。

Rails.application.routes.draw do 
    get '/handm/index' 
    root :to => "handm#index" 
end 
+0

试着做'得到 '/ handm /指数' =>“handm#index”'而不是'get'/ handm/index'' – Minato

+0

这没有奏效。 – Owen

+0

你可以给你控制器文件,以及它的名字 – Minato

回答

-1

该错误表示指定的路由或路径不存在。因此,解决方案是将其更改为有效路径。我们只能猜测你的Rails应用程序支持的路径,但是/handm#index是合理的:

Rails.application.routes.draw do 
    get '/handm/index' => 'handm#index' 
    root :to => "handm#index" 
end 
+0

这不起作用。我得到相同的错误信息 – Owen

+0

为什么要投票?有人可以向我解释吗? – archana

+0

投票意味着什么? – Owen

0
Rails.application.routes.draw do  
    get '/handm/index', to: 'handm#index' 
    root :to => "handm#index" 
end 
+0

这也没有工作。相同的错误信息。谢谢回复 – Owen

0

我已经解决了矿山,

你不需要把http://127.0.0.1:3000/index

只是这http://127.0.0.1:3000/ 因为您告诉rails以root身份进行索引。

但你会得到关于JavaScript的一个问题, 来解答你需要编辑的application.js

编辑这一行// = require_tree。 to = require_tree。

希望这将有助于

0

试试下面的代码:

的routes.rb

Rails.application.routes.draw do 
    get '/handm/index' => 'handm#index' 
    root :to => "handm#index" 
end 

handm_controller.rb

class HandmController < ApplicationController 
    def index 
    ... 
    end 
end 

views/handm/index.html。ERB

<h1>In index page</h1> 

通过命令来启动服务器:

rails server 

,打网址:

localhost:3000 

localhost:3000/handm/index 
相关问题