没有路线匹配[GET]“演示/你好”

时间:2013-09-06 22:09:53

标签: ruby-on-rails ruby

目前正在使用导轨上的红宝石,我似乎遇到了轻微的障碍。我在我的一个视图文件夹中复制了一个视图:

hello.html.erb 和 index.html.erb

尝试通过浏览器访问它时(localhost:3000 / demo /“...”) 只有原始的演示/索引有效但demo / hello有“No Route Matches”

2 个答案:

答案 0 :(得分:14)

添加

 get "demo/hello" => "your-controller#your/action"

到您的routes.rb

例如:

应用程序/控制器/ demos_controller.rb:

class DemosController < ApplicationController

  def hello
  end

end

应用程序/视图/演示/ hello.html.erb:

<p>Hello World</p>

配置/ routes.rb中:

get "demo/hello" => "demos#hello"

<强>更新 从评论中:查看rails指南了解更多详情:http://guides.rubyonrails.org/routing.html

答案 1 :(得分:0)

获取您的网址路径&#39;,以及:&#39; yourcontroller #yraction&#39; 例如。

get '/demos/hello', to: 'demos#hello'