ruby(wrong number of arguments (1 for 2) )
Ruby要求:數據表的名字和model的名字必須關聯:
1. 表名小寫,model名的第一個字母大寫;
2. 表名用復數形式(如products),model用單數形式(如Product).
在Rails2.0中,scaffold從核心中移出,轉變成插件,使用時,我們需要在所在項目里用下面的命令下載:
ruby script/plugin install scaffolding
配置好數據庫:
drop table if exists products;
create table products (
??? id int not null auto_increment,
??? title varchar(100) not null,
??? description text not null,
??? image_url varchar(200) not null,
??? price decimal(10,2) not null,
??? date_available datetime not null,
??? primary key (id)
);
然后:
ruby script/generate scaffold yourmodel [field:attribute field:attribute field:attribute]
對應數據庫語句:ruby script/generate scaffold Product title:string description:text image_url:string price:decimal
本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/qiujiaqun/archive/2009/08/06/4417970.aspx
轉載于:https://www.cnblogs.com/jiangwenwen/archive/2012/07/01/2571758.html
總結
以上是生活随笔為你收集整理的ruby(wrong number of arguments (1 for 2) )的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 利用SNMP4J实现Snmp Trap
- 下一篇: mysql数据库的备份与还原