validates_presence_of
在对应属性值为false的时候,rails会认为是空,不能通过验证。
rails版本:2.3.5
rails validates_presence_of
September 20th, 2011
moonfox rails memcache config
September 7th, 2011
moonfox config.gem "cached_model" require 'memcache' memcache_options = { :c_threshold => 10_000, :compression => true, :debug =>false, :namespace => 'my_rails_app', :readonly => false, :urlencode =>false } CACHE = MemCache.new memcache_options CACHE.servers = ['localhost:11211', 'localhost:11212']
Passing parameters to a shared example group
September 5th, 2011
moonfox shared_examples_for "a measurable object" do |measurement, measurement_methods| measurement_methods.each do |measurement_method| it "should return #{measurement} from ##{measurement_method}" do subject.send(measurement_method).should == measurement end end end
wc命令
September 3rd, 2011
moonfox wc命令用来打印文件的文本行数、单词数、字节数等(print the number of newlines, words, and bytes in files)
格式:wc -l
打印指定文件的文本行数。(l=小写L)
参数:-c, –bytes
打印字节数(print the byte counts)
参数:-m, –chars
打印字符数(print the character counts)
参数:-l, –lines
打印行数(print the newline counts)
参数:-w, –words
打印单词数(print the word counts)
memcached 启动参数
September 2nd, 2011
moonfox 启动参数
-p memcached监听的TCP端口
-l 监听的ip地址
-d 以daemon方式运行,将程序放入后台
-u memcached的运行用户
-P memcached的pid文件路径
-m memcached可以使用的最大内存数量
-c memcached同时可以接受的最大的连接数
如果你希望以socket方式来访问memcached,那么在启动的时候就必须去掉 -l和-p参数,并加上-s参数:
Aliasing “it_should_behave_like” to “it_has_behavior”
September 1st, 2011
moonfox RSpec.configure do |c| c.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:' end shared_examples_for 'sortability' do it 'responds to <=>' do sortable.should respond_to(:<=>) end end describe String do it_has_behavior 'sortability' do let(:sortable) { 'sample string' } end end
RSS Feed
Twitter
Posted in
Tags: 