一品黄土情

谷歌搜索技巧

使用谷歌搜索时的一个小技巧

  • 在使用google搜索一些GEM时在搜索条件中加入site:+期待得到某网站结果的网址
  • 使用例子如下:
  • hexo site:github.com 这样搜索到的结果都是github的记录

ruby on rails 开发时记录下的内容


  • 脚手架的使用
  • 使用例子如下:
  • rails g scaffold user name:string 这条命令会生成user modle,controller,view以及数据库文件

  • rake db 给已有数据表添加字段
  • 运行:rails generate migration add_fieldname_to_tablename
  • 去生成的DB文件修改model名,以及要添加的字段备注等等
    def change
    add_column :departments, :desc, :string,comment:'部门描述'
    end
  • 执行数据库迁移命令:rake db:migrate

  • 使用脚手架只生成controller rails g scaffold_controller aa 即:只生成aa这个controller
  • 字段名_before_type_cast 对象后加此代码即可查看枚举前的值

© 2017-2020 一品黄土情 陕ICP备17016877号

友链 小夜返回顶部

音乐加载中...
0:00