- 博客(10)
- 资源 (2)
- 收藏
- 关注
原创 RAILS关于 NIL? PRESENT? EMPTY? ANY? BLANK?
nil? nil? 判断一个具体的对象是不是为空值的。在rails常用的就是activerecord的对象判断啦。例如a查出来不是空的判断 a = User.find(1) => a.nil? => true => a.present? => false 但是字符串,空数组 ,空hash查不出来。 => "".nil? => false => [].n
2014-07-24 09:54:18
868
原创 rails migration
add_column add_index change_column change_table create_table drop_table remove_column remove_index rename_column
2014-07-14 12:09:15
541
原创 Assertions
Assertion Purpose assert( test, [msg] ) Ensures that test is true. assert_not( test, [msg] ) Ensures that test is false. assert_equal( expected, actual, [ms
2014-07-04 13:51:25
957
原创 Rails Model验证及自定义验证
自定义验证: 可以自定义validate(), 这个方法在每次保存数据时都会被调用. 如: 代码 def validate if name.blank? && email.blank? errors.add_to_base("You mustspecify a name or an email address") end end
2014-07-02 15:44:32
2185
原创 Sandi Metz' Rules For Developers
Classes can be no longer than one hundred lines of code.() Methods can be no longer than five lines of code. Pass no more than four parameters into a method. Hash options are parameters. Controller
2014-06-24 17:46:05
446
翻译 从php到Ruby
原文 https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-php/
2014-06-24 15:20:24
888
原创 Ruby全局变量
以$开始的变量是全局变量,全局变量可以在程序的任何地方加以引用。 全局变量无需变量声明。引用尚未初始化的全局变量时,其值为nil。 Ruby运行时环境预定义了一系列的全局变量,有关预定义的全局变量的信息,请参见附表。 $! 最近一次的错误信息 $@ 错误产生的位置 $_ gets最近读的字符串 $. 解释器最近读的行数(line number) $& 最近一次与正则
2014-06-24 11:59:16
637
原创 成员变量、实例变量、类变量、成员方法、实例方法、类方法的区别
类体的定义包括成员变量的定义和方法的定义。 1、成员变量包括实例变量和类变量;而成员方法包括实例方法、类方法,当然还有一种特殊的构造方法。 2、类变量、类方法就是类中的变量、方法,必须是静态的,要加static;故其又称静态变量、静态方法。 3、成员变量、成员方法是对象或实例中的变量、方法,不加static; 类变量:静态域,静态字段,或叫静态变量,它属于该类所有实例共有的属性,在
2014-06-24 11:28:47
721
转载 git/github初级运用
之前初学过一点git版本控制工具,利用github做仓库,照着github上的文档练习的了一下。不过那只篇只是照虎画猫(我的水平只能照着老虎画个猫模样,嘻嘻!)。 最近在学hibernate,公司与家之间都要调用我练习的小项目,交给git/github来管理,我只想说真的爽歪歪了。 本文在我之前的那篇《git/github学习笔记》的基础上,属于那个的升级加强版,欢迎对照阅读:http
2014-06-23 10:03:06
491
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人