Ruby on rails 简单的RubyonRails应用程序

Ruby on rails 简单的RubyonRails应用程序,ruby-on-rails,model-view-controller,ruby-on-rails-3.1,routing,haml,Ruby On Rails,Model View Controller,Ruby On Rails 3.1,Routing,Haml,我想代码简单的应用程序,与索引和关于页面,不使用数据库,所有文本将在视图。但我不能调用我的控制器方法来更改视图。 这是控制器(home\u controller.rb) 主索引视图: %h2 Index %h1 This is example page %p = link_to "Home", root_path = link_to "About", :controller => "home", :action => "index" %p "Lorem ipsum d

我想代码简单的应用程序,与索引和关于页面,不使用数据库,所有文本将在视图。但我不能调用我的控制器方法来更改视图。 这是控制器(home\u controller.rb)

主索引视图:

%h2 Index
%h1
  This is example page
%p
  = link_to "Home", root_path
  = link_to "About", :controller => "home", :action => "index"
%p
  "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
关于视图:

%h2 About
%h1
  This is about page
%p
  = link_to "Home", root_path
  = link_to "About", :controller => "home", :action => "about"
%p
  Lorem ipsum
在routes.rb中,我有
root:to=>“home#index”

当我调用我的域时,我会得到索引,当我写:domain/home/index我得到

没有与[GET]“/home/index”匹配的路由

当我打电话时,都是一样的,我怎么能叫我的页面? 请告诉我:

root/{:controller=>“home”,:action=>“index”}


您还应该定义这些路由。它们不会自动出现

例如,您可以在default generated routes.rb(末尾)中找到以下内容


取消对此的注释,您应该能够访问
/home/index
/home/about

尝试将以下内容添加到
根目录上方的路由文件中:to=>…

get 'home/index'
get 'home/about'

你确定反斜杠吗?:)模板缺少缺少带有{:handlers=>[:erb,:builder,:coffee,:haml],:formats=>[:html],:locale=>[:en,:en]}的主/关于、应用程序/关于模板。在:“/mnt/_Projects/exapmle2/app/views”wtf中搜索?我有这个你有没有
/app/views/home/about.html.haml
?ofc我有,嗯,这很有趣哦,其他地方一定有问题。你重启服务器了吗(以防万一)?我简单地创建了另一个脚手架,并删除了我不需要的东西
%h2 About
%h1
  This is about page
%p
  = link_to "Home", root_path
  = link_to "About", :controller => "home", :action => "about"
%p
  Lorem ipsum
  # This is a legacy wild controller route that's not recommended for RESTful applications.
  # Note: This route will make all actions in every controller accessible via GET requests.
  # match ':controller(/:action(/:id(.:format)))'
get 'home/index'
get 'home/about'