Skip to content

Instantly share code, notes, and snippets.

View stuartc's full-sized avatar

Stuart Corbishley stuartc

View GitHub Profile
@stuartc
stuartc / _form.html.haml
Created March 12, 2012 12:55
Datetime fields with client_side_validations gem
form_for(@user, :validate=>true) do |f|
= f.label :birthdate
= f.date_select :birthdate
= f.text_field :birthdate, :type=>"hidden", 'data-validate'=>true
end
# Used to get around the pesky camel case dbs such as MSSQL when u can't change them.
# Adds reader and writer methods for the columns.
# add 'fix_camelcase_columns' into your model.
class ActiveRecord::Base
def self.fix_camelcase_columns
define_method :after_find do
self.class.columns.each do |column|
self.instance_eval("def #{column.name.underscore}; self.#{column.name}; end;")