/ Published in: Ruby
                    
                                        
This is useful for using ActiveRecord validations without the ActiveRecord DB dependencies, this snippet is meant to be used with Textmate... create this in models/name_of_your_model to use.
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
class ${1:name_of_model} < ActiveRecord::Base
def self.columns() @columns ||= []; end
def self.column(name, sql_type = nil, default = nil, null = true)
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
end
#insert the names of the form fields here
column :name, :string
column :city, :string
column :state, :string
column :phone, :string
column :email_address, :string
#standard validations will go here
validates_presence_of :name, :email_address
end
URL: http://www.railsweenie.com/forums/2/topics/724
Comments
 Subscribe to comments
                    Subscribe to comments
                
                