/ Published in: Ruby

URL: http://www.railsweenie.com/forums/2/topics/724
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/nameofyour_model to use.
Expand |
Embed | Plain Text
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
You need to login to post a comment.