rails generate controller注释不创建它应该创建的文件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了rails generate controller注释不创建它应该创建的文件相关的知识,希望对你有一定的参考价值。
我跟随ruby on rails文档并且在这里迷上了,它似乎没有创建预期的文件,我需要一些帮助。
C:Siteslog>rails generate controller Comments
我运行上面的代码,但得到了这个。
C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load': C:/Sites/blog/config/routes.rb:10: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `block in load'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:258:in `load_dependency'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.1.4/lib/active_support/dependencies.rb:286:in `load'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/routes_reloader.rb:55:in `block in load_paths'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/routes_reloader.rb:55:in `each'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/routes_reloader.rb:55:in `load_paths'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/routes_reloader.rb:18:in `reload!'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/routes_reloader.rb:41:in `block in updater'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-5.1.4/lib/active_support/file_update_checker.rb:81:in `execute'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/routes_reloader.rb:42:in `updater'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/routes_reloader.rb:31:in `execute_if_updated'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application/finisher.rb:128:in `block in <module:Finisher>'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `instance_exec'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:30:in `run'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:59:in `block in run_initializers'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:228:in `block in tsort_each'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:431:in `each_strongly_connected_component_from'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:349:in `block in each_strongly_connected_component'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:347:in `each'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:347:in `call'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:347:in `each_strongly_connected_component'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:226:in `tsort_each'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/2.3.0/tsort.rb:205:in `tsort_each'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/initializable.rb:58:in `run_initializers'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:353:in `initialize!'
from C:/Sites/blog/config/environment.rb:5:in `<top (required)>'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:329:in `require'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/application.rb:329:in `require_environment!'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/actions.rb:16:in `require_application_and_environment!'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands/generate/generate_command.rb:19:in `perform'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command/base.rb:63:in `perform'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/command.rb:44:in `invoke'
from C:/RailsInstaller/Ruby2.3.3/lib/ruby/gems/2.3.0/gems/railties-5.1.4/lib/rails/commands.rb:16:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
- List item
请帮助我,并记录学习rails的最佳位置
答案
你的routes.rb
在某处有错误。备份现有的routes.rb
文件,然后将其更改为,
Rails.application.routes.draw do
end
然后运行您的generate命令。然后,将之前的内容添加回routes.rb
以上是关于rails generate controller注释不创建它应该创建的文件的主要内容,如果未能解决你的问题,请参考以下文章
Rails:当模型已经存在时,如何运行`rails generate scaffold`?
“$ rails generate model Model”在Rails 5中生成了两个模型
如何在 Cloud9 上使用 Rail 的 generate 生成脚手架文件
“_from.erb”上的“rails generate scaffold”错误(jbuilder问题?)
在 f.label 中嵌套输入(rails form generation)
Rails 不会编译资产,但会在日志中显示编译,rake assets:precompile not generate files