Error with Generate Scaffold Micropost
I'm following the http://ruby.railstutorial.org/ From my application directory I run this command but receive the error below. I have searched around but can figure out how to fix.
$ rails generate scaffold Micropost content:string user_id:integer
This is the error:
/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 `ru开发者_如何学Pythonn_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>'
My routes.rb is:
DemoApp::Application.routes.draw do
resources :users
.
.
.
end
The key is in the first line of the error message.
/config/routes.rb:4: syntax error, unexpected '.' (SyntaxError)
Then in your routes file, notice that you have those periods, which do not belong.
DemoApp::Application.routes.draw do
resources :users
.
.
.
end
Remove the periods.
DemoApp::Application.routes.draw do
resources :users
end
精彩评论