Copied from Rails Weenie
class Contact < 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
column :name, :string
column :city, :string
column :state, :string
column :phone, :string
column :email_address, :string
validates_presence_of :name, :email_address
end
On 11/28/05, List Recv <listrecv-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Any way to run validations on fields which aren''t in the SQL?
>
> I know there have been some posts about validations on non persistent
> objects. I''m talking about validations on nonpersisted fields of
> persisted objects.
>
> In general, it seems to me that the validations code is very useful,
> totally outside of persistence. Perhaps it should be taken out and made
> a mixin?
>
> (Is there a Rails equivalent of RCR''s?)
>
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
First they laugh at you, then they ignore you, then they fight you.
Then you win.
-- Mahatma Karamchand Gandhi
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails