0

我正在尝试创建一个静态页面。我输入$ rails generate controller StaticPages home help --no-test-framework并得到下面的输出。

    conflict  app/controllers/static_pages_controller.rb
Overwrite   
/Users/themaktravels/rails_projects/sample_app/app/controllers/static_pages_controller.rb?   (enter "h" for help) [Ynaqdh] d
  class StaticPagesController < ApplicationController
-   def ...
+   def home
+   end
+ 
+   def help
    end
  end
Retrying...

我试图看看有什么区别,但我不熟悉这个以了解区别是什么。当我尝试不覆盖文件然后测试 URL 时,我的页面上出现此错误。

Routing Error

No route matches [GET] "/static_pages/home"

Try running rake routes for more information on available routes.

然后我尝试使用 GIT 检查我的更改,然后尝试运行 rake 路由

bundle update rake

bundle show rake 

require 'rake/dsl_definition'

但我的静态页面仍然显示错误。有什么建议么?谢谢!

4

1 回答 1

0

将此添加到您的路线文件中

配置/路由.rb

get "static_pages/home"
get "static_pages/help"

高温高压

于 2012-11-27T06:32:42.443 回答