This post originated from an RSS feed registered with Java Buzz
by Paul Kilroy.
Original Post: Running Rails on OS X with MySQL 5.0.24
Feed Title: The Frustrated Programmer
Feed URL: http://liberty.phpwebhosting.com/404.html
Feed Description: The problems I encounter on a daily basis, blogged for posterity. All content will be original, contain poor grammar and a few mispellings.
While installing all the pre-requisites for running Rails on my new Mac Pro, I ran across a problem with either the mysql gem or mysql 5.0.24 where it depends on 'ulong' being defined by the OS include files. On OS X it isn't, and this causes the ruby mysql gem to fail compilation which causes Rails to (possibly) throw a Lost Connection to MySQL Server during query error due to the fact that the built-inc.parse('this tuesday 5:00', :ambiguous_time_range => :none)
#=> Tue Aug 29 05:00:00 PDT 2006
Chronic.parse('may 27th', :now => Time.local(2000, 1, 1))
#=> Sat May 27 12:00:00 PDT 2000
Chronic.parse('may 27th', :guess => false)
#=> Sun May 27 00:00:00 PDT 2007..Mon May 28 00:00:00 PDT 2007
The thing I find really nice is that if you pass it a malformed date, it returns nil. This means, in your model validations, you can add:
require 'chronic'
class Meeting < ActiveRecord::Base
def validation
errors.add :meeting_date, 'is not a valid date' if Chronic.parse(meeting_date.to_s).nil?
end
end