Scaffold fuction not working properly

100 views
Skip to first unread message

Chris Willis

unread,
Dec 21, 2007, 11:56:20 AM12/21/07
to rubyonra...@googlegroups.com
Hey guys,
i have just set up a database and ruby on rails application. I then did
a ruby script\generate Product Admin which should give it all of the
nessasary parts to run as a web app. Instead it did this:

C:\ruby\depot>ruby script\generate scaffold Product
exists app/models/
exists app/controllers/
exists app/helpers/
create app/views/products
exists app/views/layouts/
exists test/functional/
exists test/unit/
create app/views/products/index.html.erb
wrong number of arguments (1 for 2)


How can i fix this?
Thanks
Chris
--
Posted via http://www.ruby-forum.com/.

Leonardo

unread,
Dec 21, 2007, 1:12:23 PM12/21/07
to Ruby on Rails: Talk
Are you using Rails 2.0?

If so, provide your scaffold with your model's definition, liike this:
ruby script\generate scaffold Product code:integer name:string

Make sure your you destroy your model first.

I posted something related to this here:
http://leonardoborges.com/writings/2007/12/21/rails-20-scaffold/

Hope it helps

On Dec 21, 1:56 pm, Chris Willis <rails-mailing-l...@andreas-s.net>
wrote:

Brian Hogan

unread,
Dec 21, 2007, 4:52:53 PM12/21/07
to rubyonra...@googlegroups.com
My assumption is that the original poster is trying to follow the Agile Web Development with Rails book which is not compatible with Rails 2.0

My suggestion is to uninstall Rails

gem uninstall rails

then reinstall the specific version that will work with that book

gem install version=1.2.6 rails

Then, recreate the depot application

rails depot

That will allow you to complete the book, afterwhich you can upgrade to Rails 2.0.

Brian Hogan

unread,
Dec 21, 2007, 4:54:38 PM12/21/07
to rubyonra...@googlegroups.com
Ack... mistake in my commands.

To install Rails 1.2.6, you should do

gem install --version=1.2.6 rails   - I forgot the two --

George Bailey

unread,
Dec 21, 2007, 5:08:26 PM12/21/07
to rubyonra...@googlegroups.com

On Dec 21, 2007, at 10:56 AM, Chris Willis wrote:

> C:\ruby\depot>ruby script\generate scaffold Product


You're leaving out the controller name. If you're following the book
It should be

ruby script/generate scaffold product admin


Chris Willis

unread,
Dec 21, 2007, 5:08:49 PM12/21/07
to rubyonra...@googlegroups.com
Thanks
You guessed it!
I will do that

Vinod Jain

unread,
Jan 1, 2008, 11:24:21 PM1/1/08
to rubyonra...@googlegroups.com

I am also having the same problem.

command: ruby script/generate scaffold product admin
the above command creates controller as well as default view.


command: ruby script\generate scaffold Product code:integer name:string
In the above command, I don't specify controller, so how will the
controller and views will be created?

Thanks.

Vinod

Jeremy McAnally

unread,
Jan 1, 2008, 11:35:44 PM1/1/08
to rubyonra...@googlegroups.com
The new scaffolds are RESTful, so they derive their controller name
from the model name (e.g., Product -> ProductsController).

Look up information on REST and RESTful Rails for more explanation.

--Jeremy

--
http://www.jeremymcanally.com/

My books:
Ruby in Practice
http://www.manning.com/mcanally/

My free Ruby e-book
http://www.humblelittlerubybook.com/

My blogs:
http://www.mrneighborly.com/
http://www.rubyinpractice.com/

Alex Birkett

unread,
Jun 17, 2008, 9:26:33 AM6/17/08
to rubyonra...@googlegroups.com

I trying to follow the AWDWR 2nd Edition book and I've seen your
suggestion in other place too. I can't see the point though, what is the
point on learning an obsolete version of rails when the new one is
obviously so different! Does anybody know how to work around this
problem with Rails 2.x?

Alex Birkett

unread,
Jun 17, 2008, 10:00:37 AM6/17/08
to rubyonra...@googlegroups.com
Leonardo wrote:
> Are you using Rails 2.0?
>
> If so, provide your scaffold with your model's definition, liike this:
> ruby script\generate scaffold Product code:integer name:string
>
> Make sure your you destroy your model first.
>
> I posted something related to this here:
> http://leonardoborges.com/writings/2007/12/21/rails-20-scaffold/
>
> Hope it helps
>
> On Dec 21, 1:56�pm, Chris Willis <rails-mailing-l...@andreas-s.net>

You don't need to destroy the model!

The command:

ruby script\generate scaffold Product

will create a controller called Products. I'm just using that controller
instead of the admin one.

Nellboy

unread,
Jun 17, 2008, 12:01:32 PM6/17/08
to Ruby on Rails: Talk
The new version of Rails isn't actually so different from what I can
see - although i'm still learning also, so I'm open to correction
there...

what the scaffold does now is to generate the view, controller, and
model all in one... it also generates a database migration file (in
the db folder) which can be edited before performing a rake db:migrate
to create the database table with relevant fields... it's not really
too complex...
Reply all
Reply to author
Forward
0 new messages