该命令成功运行,并表示已创建文件,但没有创建文件,再次运行该命令表示它们已存在。
<{1>}之后<{1>},rails generate controller
:
~/Desktop/Projects/RailsTutorial
create app/controllers/static_pages_controller.rb
invoke erb
create app/views/static_pages
invoke test_unit
create test/controllers/static_pages_controller_test.rb
invoke helper
create app/helpers/static_pages_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/static_pages.coffee
invoke scss
create app/assets/stylesheets/static_pages.scss
上的 ls
:
~/Desktop/Projects/RailsTutorial/app/controllers
答案 0 :(得分:0)
您是否在控制器名称后添加了一个方法?要在config / routes.rb中拥有erb视图文件和路由,您还需要使用控制器创建一个方法。
bundle exec rails g controller Recipes index
create app/controllers/recipes_controller.rb
route get 'recipes/index'
invoke erb
create app/views/recipes
create app/views/recipes/index.html.erb
invoke test_unit
create test/controllers/recipes_controller_test.rb
invoke helper
create app/helpers/recipes_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/recipes.coffee
invoke scss
create app/assets/stylesheets/recipes.scss