Working

Paperclip 验证上传文件大小时 allow_nil 无法工作的解决方法

Posted on

paperclip可以通过 validates_attachment_size 来验证上传文件的大小,但当使用 allow_nil => true 参数时,上传文件为空一样会抛错,这是Paperclip 2.3.1.1的bug。 解决方法: 打开paperclib.rb,找到validates_attachment_size,把最后一段 validates_inclusion_of :”#{name}_file_size”, :in      => range, :message => message, :if      => options[:if], :unless  => options[:unless] 改成: validates_inclusion_of :”#{name}_file_size”, options.merge(:in => range, :message => message) 就可以了 参考:http://github.com/thoughtbot/paperclip/issues/issue/134

Working

Web Wednesday December, Featuring Leslie Lee

Posted on

We would like to invite you to the following event: WEB WEDNESDAY – GUANGZHOU Date: 2009-12-23 – 7 pm, The Paddy Field 田野西餐吧 No admission fee, no registration required A direct descendant of Hong Kong’s successful networking event. Meet the GZ “Digerati” and greet guests from around Asia who are leaders on the Internet! Our […]

Working

Problems I've met after upgrading to Snow Leopard

Posted on

I upgraded my Mac OS X Leopard to Snow Leopard a couple days ago. Everything seems to be fine, system runs faster than before in general. But a couple of softwares doesnt work compatible with SL. The 1st one is mysql, after upgrading, it’s completely gone, I just cannt find it. Then I try to […]

Working

Google Developer Day 2009

Posted on

[font=Verdana][size=4]Last Friday, I attended the amazing Google Developer Day 2009! It’s a set of one-day developer events, and a very good chance to learn about latest products from engineers who built them, including Google Maps, OpenSocial, HTML 5, O3D, Android and the most exiting Google Wave! And this is the first time I have chance […]

Working

实战 ubuntu 8.04 下安装部署Apache2 + Rails + Passenger + Mysql

Posted on

安装Apache2,Rails,Passenger,Mysql的过程就不多说了,网上一搜教程一大堆,基本上按照默认的设置就可以跑起来了,所以只讲讲其中遇到的问题吧。 Passenger安装参考:http://www.railsgarden.com/2008/04/12/configurating-passenger-mod_rails-on-slicehost-with-ubuntu-710/ http://shiningray.cn/passenger-mod_rails-introduction.html 安装好所有东西再设置好之后,访问网站发现页面显示passenger出错,但没有指明详细错误,查看apache的log之后,发现是内存不够,当时的vps内存有192mb。无奈之下弃用Passenger,转用Mongrel Cluster。再设置好之后天色已经大亮,反正网站也跑起来了,择日再战。 Mongrel Cluster 安装参考(我没有装nginx):http://www.linuxdiyf.com/bbs/thread-68560-1-82.html http://www.javaeye.com/topic/145294 数天之后,vps的内存升级到了256mb,于是我再次尝试用Passenger。 把mongrel server停掉,再把mongrel的启动文件从/etc/init.d/,/etc/rc*.d/中删除。在apache的启动设置中加入passenger,restart apache server。 访问页面,哦,出来了,开心。 但没开心多久,server 又 crash掉了。查看project log,没发现问题,再查看apache log,也没有问题,我日! 最后不经意查看 /var/log/kern.log时,发现两句:Feb 13 05:49:32 localhost kernel: [ 3675.264499] Out of memory: kill process 4445 (apache2) score 85884 or a childFeb 13 05:49:32 localhost kernel: [ 3675.264516] Killed process 4445 (apache2) 原来又是内存不够的问题!! 但既然一开始可以跑起来,那应该可以继续的啊,手头的project不是很大,数据结构不是很复杂,数据量也不大啊,见鬼了! 继续Google之,在http://www.aldenta.com/2008/09/25/phusion-passenger-mod_rails-memory-management/发现,如果vps的内存不是很大,最好在apache的passenger设置文件里加入 PassengerMaxPoolSize 2 […]

Working

New logo for my working site

Posted on

The website provide current train, ferry, and bus schedules in the Pearl River Delta for 17 companies and 7 locations. Well,the domain may not be “.com”.’Cause .com is register by someone else. [img][attach]46[/attach][/img]