1

そのため、データベースをセットアップし、作成したアプリの足場を生成しようとしました。このエラーが発生し、少し混乱しています。何かアドバイス?ありがとう!

rails generate scaffold product title:string description:text image_url:string
/Users/Cameron/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>): could not find expected ':' while scanning a simple key at line 18 column 3 (Psych::SyntaxError)
from /Users/Cameron/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
from /Users/Cameron/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/psych.rb:151:in `parse'
from /Users/Cameron/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/psych.rb:127:in `load'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application/configuration.rb:115:in `database_configuration'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/railtie.rb:78:in `block (2 levels) in <class:Railtie>'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activesupport-3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/base.rb:720:in `<top (required)>'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/Cameron/depot/config/environment.rb:5:in `<top (required)>'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:103:in `require'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/application.rb:103:in `require_environment!'
from /Users/Cameron/.rvm/gems/ruby-1.9.3-p392/gems/railties-3.2.13/lib/rails/commands.rb:25:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
4

1 に答える 1

4

これはおそらくconfig/database.ymlファイルの問題です。エラーは、Ruby の YAML 解析エンジンである Psych からのものです。実行中に読み取られる他の YAML ファイルについては知りません。ファイルrails g scaffoldにタイプミスを導入することで、その失敗を再現できdatabase.ymlます。

デバッグに役立つようにファイルを貼り付けることができるオンライン YAML バリデーターがいくつかあります。問題が見つからない場合は、上記の質問に追加してください。

于 2013-03-24T17:15:02.357 に答える