Forum: Ruby on Rails yaml Error When Trying to Generate Scaffold

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
102c8211565c477be8d3867875f69837?d=identicon&s=25 untz786 (Guest)
on 2005-12-02 01:25
(Received via mailing list)
Hello there,

I am a Ruby on Rails newbie, and have been reading the book, "Agile
Web Development with Rails", by Dave Thomas.

Seem to be stuck on page 57, when trying to invoke "ruby script/
generate scaffold Product Admin"...

My depot/config/database.yml file's contents are:

development:
   adapter: mysql
   database: depot_development
   socket: /tmp/mysql.sock
   username: untz
   password: paintball

# Warning: The database defined as 'test' will be erased and
# re-generated from your development database when you run 'rake'.
# Do not set this db to the same as development or production.
test:
   adapter: mysql
   database: depot_test
   socket: /tmp/mysql.sock
   username: untz
   password:     paintball

production:
   adapter: mysql
   database: depot_production
   socket: /tmp/mysql.sock
   username: untz
   password: paintball

When I created these tables using MySQL 5, I issued the following in
the MySQL Command Line Monitor:

grant all on depot_development.* to 'untz'@'localhost' identified by
'paintball';
grant all on depot_test.* to 'untz'@'localhost' identified by
'paintball';
grant all on depot_production.* to 'untz'@'localhost' identified by
'paintball';

When I tried to generate a scaffold, this is the error I received:

Raven:/Developer/DevResources/Ruby/RailsApps/depot untz$ ruby script/
generate scaffold Product Admin
/usr/local/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line
19, col -2: `production: (ArgumentError)
   adapter: mysql
   database: depot_production
   socket: /tmp/mysql.sock
   username: untz
   password: paintball
'       from /usr/local/lib/ruby/1.8/yaml.rb:133:in `load'
         from /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/
initializer.rb:419:in `database_configuration'
         from /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/
initializer.rb:163:in `initialize_database'
         from /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/
initializer.rb:80:in `process'
         from /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/
initializer.rb:40:in `run'
         from ./config/environment.rb:10
         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:21:in `require'
         from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.3/
lib/active_support/dependencies.rb:214:in `require'
         from /usr/local/lib/ruby/gems/1.8/gems/rails-0.14.3/lib/
commands/generate.rb:1
         from /usr/local/lib/ruby/site_ruby/1.8/rubygems/
custom_require.rb:21:in `require'
         from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.3/
lib/active_support/dependencies.rb:214:in `require'
         from script/generate:3

I am using ruby 1.8.3 (2005-09-21) [powerpc-darwin8.2.0] on OS X
Tiger and Rails 0.14.3...

Is the Ruby 1.8.3's yaml corrupt?

Please help! I am at this point, stuck... I really want to learn
"Ruby on Rails", so any
tips, suggestions, and hints would be greatly appreciated.

Is there a setting in Rails where I change a configuration to point
to the prospective Ruby 1.8.3 on my local machine?

Do I need to re-install Ruby 1.8.2?

Many, many thanks!

-Unnsse
90a73d9875462aaa9fab2feffafbffe7?d=identicon&s=25 ben (Guest)
on 2005-12-02 01:41
(Received via mailing list)
On Thu, Dec 01, 2005, untz wrote:
> /usr/local/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line
> 19, col -2: `production: (ArgumentError)

The error that you're seeing often indicates a whitespace problem in the
YAML.  Tabs are illegal in YAML so make sure that all of the whitespace
in your file truly are spaces and not tabs.

If that doesn't work, there may be something else going on, but that's a
good place to start.

Ben
90a73d9875462aaa9fab2feffafbffe7?d=identicon&s=25 ben (Guest)
on 2005-12-02 01:45
(Received via mailing list)
On Thu, Dec 01, 2005, untz wrote:
> # Warning: The database defined as 'test' will be erased and
> # re-generated from your development database when you run 'rake'.
> # Do not set this db to the same as development or production.
> test:
>   adapter: mysql
>   database: depot_test
>   socket: /tmp/mysql.sock
>   username: untz
>   password:     paintball

On a second glance, it also might be those extra spaces between
'password:' and 'paintball'.  Make sure that's not a tab and that
there's only one space.

Ben
102c8211565c477be8d3867875f69837?d=identicon&s=25 untz786 (Guest)
on 2005-12-02 09:24
(Received via mailing list)
Ok, that's a good observation... On gvim, it doesn't show the tab and
using pico, it does show the spaces....

When I fixed it and re ran the attempt to generate a scaffold, this
is the new error I got:

ruby script/generate scaffold Product Admin
       exists  app/controllers/
       exists  app/helpers/
       exists  app/views/admin
       exists  test/functional/
   dependency  model
       exists    app/models/
       exists    test/unit/
       exists    test/fixtures/
    identical    app/models/product.rb
    identical    test/unit/product_test.rb
    identical    test/fixtures/products.yml
       create  app/views/admin/_form.rhtml
Permission denied - ./app/views/admin/_form.rhtml

Any suggestions?

Many, many thanks!

-Unnsse
This topic is locked and can not be replied to.