我正在关注http://ruby.railstutorial.org/从我的应用程序目录运行此命令但收到以下错误。我已经四处寻找,但可以弄清楚如何解决。
$ rails generate scaffold Micropost content:string user_id:integer
这是错误:
/Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `load': /Users/bryonthomas/Code/demo_app/config/routes.rb:4: syntax error, unexpected '.' (SyntaxError)
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `block in load'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/dependencies.rb:235:in `load'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:127:in `block in reload_routes!'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:127:in `each'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:127:in `reload_routes!'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:120:in `block in routes_reloader'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/file_update_checker.rb:32:in `call'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/activesupport-3.0.9/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application/finisher.rb:51:in `block (2 levels) in <module:Finisher>'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application/finisher.rb:52:in `call'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:25:in `run'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `each'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:134:in `initialize!'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:77:in `method_missing'
from /Users/bryonthomas/Code/demo_app/config/environment.rb:5:in `<top (required)>'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:103:in `require'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/application.rb:103:in `require_environment!'
from /Users/bryonthomas/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/commands.rb:16:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
我的routes.rb是:
DemoApp::Application.routes.draw do
resources :users
.
.
.
end
答案 0 :(得分:1)
密钥位于错误消息的第一行。
/config/routes.rb:4: syntax error, unexpected '.' (SyntaxError)
然后在你的路线文件中,注意你有那些不属于的时期。
DemoApp::Application.routes.draw do
resources :users
.
.
.
end
删除期间。
DemoApp::Application.routes.draw do
resources :users
end