简单问题,ruby script/generate scaffold 总是出错?

guhguh 2007-05-13 10:22:46
D:\ROR\addressbook1>ruby script/generate scaffold contact admin
exists app/controllers/
exists app/helpers/
exists app/views/admin
exists app/views/layouts/
exists test/functional/
dependency model
exists app/models/
exists test/unit/
exists test/fixtures/
identical app/models/contact.rb
identical test/unit/contact_test.rb
identical test/fixtures/contacts.yml
wrong number of arguments (1 for 0)



结果总是

wrong number of arguments (1 for 0)



请问这是什么问题啊,我是新生,帮帮忙啊,
我的据库连接没有问题啊!
...全文
1490 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
蓝天星空 2012-07-22
  • 打赏
  • 举报
回复
ruby script/generate scaffold -h
查看帮助即可
蓝天星空 2012-07-22
  • 打赏
  • 举报
回复
你的rails 如果是2.0的话,命令和1.0的就不一样啦。
我的是版本问题造成的!
ruby script/generate scaffold product title:string description:string image_url:string price:float data_available:string

suro2000 2008-08-28
  • 打赏
  • 举报
回复
去下载instantXX 在ruby的官方网站上,windows集成的环境,里面有1.7版本的。用这个做例子没问题。
Albert_2017 2008-08-19
  • 打赏
  • 举报
回复
你的这种写法是rails 1.0里面的
在rails 2.0里面不是这样的.可以上网查一下
愤怒的小蒋 2008-06-23
  • 打赏
  • 举报
回复
2.0以后就不能这么用了 小伙子
cocolong2002 2008-05-25
  • 打赏
  • 举报
回复
我遇到的是同样的问题,经过网络搜索,找到了答案。按以下解释现已解决。
Following the Rails 2.0 hype, I’ve been playing around with it and decided to share a first impression: Scaffolding is gone!

But wait, before you knock your head against the wall, let me tell you something: I lied

Scaffolding is not really gone. It’s just changed a bit.

How can I tell? Well, as a good developer I thought: “I’ll just create a scaffold with the new version and see what’s different”

I fired up a terminal, created a news rails application and generated a new model:

$ script/generate model Contact name:string email:string - yes you can do this in rails 2.0, and these fields get into your model’s migration!

Now the I have a new model, it’s time for a controller to manage it:

$ script/generate controller Contacts

So your controller would look something like this huh?

class ContactsController < ApplicationController
scaffold :contact
end

Well, too bad! The method scaffold is gone from ActionController::Base! And I’m not lying this time!

Now that the dynamic scaffold is gone, we’re left with the static one.
Ok, let’s try it then:

$ script/generate scaffold contact

And it won’t work again! At the end of the output, you will get something like this:

Another migration is already named create_contacts: db/migrate/001_create_contacts.rb

It really means that if your model is meant to be used by a scaffold, you better generate it in the same line. It will fail, afaik, if the model previously existed. Destroy yout model and controller, and execute the following:

$ script/generate scaffold Contact name:string email:string

Done! Just run your migrations, startup your server and your new scaffold in rails 2.0 will be working gracefully!

It took me a while to discover this changes because I didn’t find it well documented. But maybe I was not looking in the right places.

jianxm 2008-05-08
  • 打赏
  • 举报
回复
在Rails2.0中,scaffold从核心中移出,转变成插件,使用时,我们需要在所在项目里用下面的命令下载:

ruby script/plugin install scaffolding

配置好数据库之后,像往常一样用


ruby script/generate scaffold yourmodel [field:attribute field:attribute field:attribute]
taito 2008-05-05
  • 打赏
  • 举报
回复
================================================
在Rails2.0中 scaffold功能不能用原方法
wrong number of arguments (1 for 2)
================================================
这是因为rails的静态脚手架scaffold 用法与之前的不一样了
新的用法格式是:ruby script/generate scaffold ModelName [field:type, field:type]
举个例子,执行ruby script/generate scaffold product title:string description:text image_url:string,
*在Netbean 中,你不必在自己定义Controller Name
knowledge_Is_Life 2008-05-01
  • 打赏
  • 举报
回复
好像没那么简单,呵呵.
meiZiNick 2008-05-01
  • 打赏
  • 举报
回复
不明LZ在说什么
UltraBejing 2008-04-30
  • 打赏
  • 举报
回复
这个简单啊,网上搜一下就得到答案了.
lgn21st 2007-10-13
  • 打赏
  • 举报
回复
ruby script/generate scaffold -h
runningstar 2007-10-10
  • 打赏
  • 举报
回复
Ruby要求你的数据表的名字和model的名字必须有关联:
1. 表名小写,model名的第一个字母大写;
2. 表名用复数形式(如contacts),model用单数形式(如Contact).
python二级题库 2007-07-24
  • 打赏
  • 举报
回复
幫頂一下!
mathsfan 2007-05-15
  • 打赏
  • 举报
回复
你数据库里面有contacts这个表吗?

2,763

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ruby/Rails
社区管理员
  • Ruby/Rails社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧