博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ruby(wrong number of arguments (1 for 2) )
阅读量:7029 次
发布时间:2019-06-28

本文共 751 字,大约阅读时间需要 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博客,转载请标明出处:

转载于:https://www.cnblogs.com/jiangwenwen/archive/2012/07/01/2571758.html

你可能感兴趣的文章
NOJ-1162-简单编码
查看>>
jsp页面执行原理及获取上下文根方式
查看>>
牛客小白月赛6 E 对弈 思维
查看>>
linux RAC 安装失败完全卸载
查看>>
自己封装了一个EF的上下文类.,分享一下,顺便求大神指点
查看>>
Http的Get和Post--扫盲篇
查看>>
xdebug 配置
查看>>
Linux(Ubuntu)之设定开机自启动
查看>>
http状态码的分类
查看>>
react native redux saga增加日志功能
查看>>
hibernate缓存机制(二级缓存)
查看>>
iOS 小方法
查看>>
php 快速fork出指定个子进程
查看>>
1、算法简介
查看>>
HDU 4278 卡特兰,区间DP
查看>>
04分类整理:会搜索还不够,整理、分类、归纳
查看>>
线索二叉树【C语言】
查看>>
hdu Can you solve this equation?
查看>>
【CLRS】《算法导论》读书笔记(四):栈(Stack)、队列(Queue)和链表(Linked List)...
查看>>
hibernate 和 mybatis区别
查看>>