覆盖冲突app / controllers / static_pages_controller.rb?

时间:2012-11-27 04:51:24

标签: ruby-on-rails rake static-pages

我正在尝试创建一个静态页面。我输入了$ 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'

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

1 个答案:

答案 0 :(得分:0)

将此添加到路线文件

配置/ routes.rb中

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

HTH