Topic: generate scaffold with rails 1.2.3

I'm following Apple's tutorial from last year and I'm wondering how to get this part:
[code=command line]script/generate scaffold account expenses[/code] to work.

When I try to run it I get an error:

[code=command line]Ras:/usr/local/src/readline-5.1/expenses $ script/generate scaffold account expenses
wrong number of arguments (1 for 2)[/code]

rails -v: Rails 1.2.3
ruby -v: ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]

Is there any other way to get this to work ?
Are there any tutorials available on how to make a small application with the current rails version?

Re: generate scaffold with rails 1.2.3

Hmm, that's strange you are getting that error. It looks correct to me. Is there more information about the error? Did it give you a stack trace with it?

Railscasts - Free Ruby on Rails Screencasts

Re: generate scaffold with rails 1.2.3

This is what trace puts [code=command line]Ras:~/expenses $ script/generate scaffold account expenses -t
wrong number of arguments (1 for 2)
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/base.rb:221:in `attributes'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/base.rb:220:in `collect'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/base.rb:220:in `attributes'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:69:in `manifest'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/base.rb:159:in `record'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/manifest.rb:21:in `initialize'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/base.rb:159:in `new'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/base.rb:159:in `record'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb:29:in `manifest'
  (eval):3:in `__send__'
  (eval):3:in `manifest'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/commands.rb:42:in `invoke!'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/rails_generator/scripts/../scripts.rb:31:in `run'
  /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3.6752/lib/commands/generate.rb:6
  /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
  /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
  script/generate:3[/code]

Re: generate scaffold with rails 1.2.3

Hmm, that's not as helpful as I was hoping. Did you follow the "script/generate migration" instructions before that? Try running "rake db:migrate" again. Also double check your code to make sure there's no variations.

Railscasts - Free Ruby on Rails Screencasts

Re: generate scaffold with rails 1.2.3

I tried again 2 times and I still got the same error. Maybe it's time to try another tutorial.

Re: generate scaffold with rails 1.2.3

Which OS are you using?

If M$ then you should prefix your commands with ruby.

Example

ruby script/generate scaffold account expenses

Re: generate scaffold with rails 1.2.3

One idea, perhaps scaffolding now relies on there being an Account model. Try running this command:

script/generate model account

Railscasts - Free Ruby on Rails Screencasts

Re: generate scaffold with rails 1.2.3

I am getting the same error as well.
Using Aptana RadRails or the command line I input:

ruby script/generate scaffold Product Admin

and get the following output:
 exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      exists  app/views/accounts
      exists  app/views/layouts/
      exists  test/functional/
      exists  test/unit/
wrong number of arguments (1 for 2)

Any idea why this might be? This didn't use to happen with my old Instant Rails and before Aptana updated. However, i don't think this is the problem. Please, any help is appreciated.

Re: generate scaffold with rails 1.2.3

I'm having exactly the problem, either on Aptana or command line.

I'm using Rails 2.0.2, ruby 1.8.6.

Did you find a solution?

Re: generate scaffold with rails 1.2.3

Yes... I am getting the same problem. This seems to be a new and recurring problem.

I am running RoR on a windows, when I  script/generate scaffold Products Admin
I get:

exists app/models/ 
exists app/controllers/
exists app/helpers/
exists app/views/products
exists app/views/layouts/
exists test/functional/
exists test/unit/

wrong number of arguments (1 for 2)
I'm running Ruby 1.8.5 (2006-12-25 patchlevel 12)
and Rails 2.0.2

help with the wrong arguments... my files aren't being created by beautiful Ruby.

Last edited by Yozef (2008-02-17 04:39:07)

Re: generate scaffold with rails 1.2.3

Hi,

Having the same problem. Any solutions yet?

Rails 2.0.2
Ruby 1.8.6
OS X 10.5.2

Re: generate scaffold with rails 1.2.3

Same problem here...

>script/generate scaffold recipe recipe
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/recipes
      exists  app/views/layouts/
      exists  test/functional/
      exists  test/unit/
      create  app/views/recipes/index.html.erb
wrong number of arguments (1 for 2)

Tried both "regular" rails and via Aptana Studio with both sqlite3 and sqlite2 -- no go. And all I've been doing is following instructions and tutorials. Even tried recreating the project, but nothing seems to work.

A trace gives this...

wrong number of arguments (1 for 2)
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/base.rb:222:in `initialize'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/base.rb:222:in `new'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/base.rb:222:in `attributes'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/base.rb:221:in `collect'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/base.rb:221:in `attributes'
  C:/ruby/lib/ruby/1.8/delegate.rb:270:in `__send__'
  C:/ruby/lib/ruby/1.8/delegate.rb:270:in `method_missing'
  (erb):5:in `template'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/commands.rb:290:in `template'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/commands.rb:267:in `identical?'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/commands.rb:267:in `open'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/commands.rb:267:in `identical?'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/commands.rb:213:in `file'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/commands.rb:287:in `template'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/manifest.rb:47:in `send'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/manifest.rb:47:in `send_actions'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/manifest.rb:46:in `each'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/manifest.rb:46:in `send_actions'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/manifest.rb:31:in `replay'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/commands.rb:42:in `invoke!'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/rails_generator/scripts/../scripts.rb:31:in `run'
  C:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/commands/generate.rb:6
  C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
  C:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
  script/generate:3
>

Last edited by noccy (2008-03-19 09:20:57)

Re: generate scaffold with rails 1.2.3

Scaffold is expecting a data description of expenses.  That is why you are missing an argument. 

The syntax is generate scaffold modelname fieldname:type fieldname2:type .......

This will work...

ruby script/generate scaffold account expenses:decimal

Re: generate scaffold with rails 1.2.3

if we have to as data descriptions to the scaffold then for a 20 entry table we have to put the description in for each field in the table.  Seems harsh