rails常用命令

来源:互联网 发布:网络社区营销优点 编辑:程序博客网 时间:2024/05/01 00:55

rails new demo -d mysql使用mysql新建一个项目

rails g controller welcome新建一个welcome的控制器

rake db:create根据配置创建空的数据库

rails g scaffold person name:string bio:text birthday:date创建person对象的映射,以及增删改查页面

rake db:migrate执行db/migration下面的所有文件(用于对数据库的操作)

rails g model event name:string description:text is_public:boolean capacity:integer创建event对象的映射(相比较scaffold不会生成增删改查的页面)

rails g migration add_status_to_events 创建一个migration


#典型路由:它會將/foo/bar這樣的網址自動對應到Controller foo的bar Action
match ':controller(/:action(/:id))(.:format)'

rake stats列出代码数等

开启一个rails主控台

rails console

rails c

rails c --sandbox(在沙箱中打开)

启动服务

rails s -p 4000 -e production

所有用到的 Gems 打包进 vendor/cache 

bundle package

列出所有的URL HelperURL网址和对应的Controller Action

rake routes










原创粉丝点击