Forum: Ruby on Rails ActiveRecord subclassing best practises

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Oscar Picasso (Guest)
on 2006-04-06 16:46
(Received via mailing list)
Hi,

I want some of my models to inherit from a custom ActiveRecord::Base
class. Where is the best place to put this custom subclass?

Actually, I just wanted to translate the default validate message so
maybe there was a better thing to do than subclassing
ActiveRecord::Base.

Thanks

Oscar
Alan F. (Guest)
on 2006-04-06 17:01
Oscar Picasso wrote:
> Hi,
>
> I want some of my models to inherit from a custom ActiveRecord::Base
> class. Where is the best place to put this custom subclass?
>
> Actually, I just wanted to translate the default validate message so
> maybe there was a better thing to do than subclassing
> ActiveRecord::Base.


Oscar,

You can supply a custom message to the validates_* methods.

See:
http://api.rubyonrails.org/classes/ActiveRecord/Va...

e.g.

validates_length_of :last_name, :maximum=>30, :message=>"less than %d if
you don't mind"

A.
This topic is locked and can not be replied to.