Hi Jim,Unfortunately, validations aren't magically overridden by Desert the
way methods are. To override validations, put some custom logic in an
after_validation filter, and/or implement the 'validate' method i.e.:

class Photo < ActiveRecord::Base

  after_validation :custom_validations

  ... stuff ...

  def custom_validations
    self.errors.remove(:user) #you don't want to validate user
  end

  def validate
    errors.add("name", "must not be blank") if name.blank? #you want to
require the name attribute
  end

end

That errrors.remove method is a hack (put this in an initializer):

module ActiveRecord
  class Errors
    #removes all errors on the given attribute
    def remove(attribute)
      @errors.delete(attribute.to_s)
    end
  end
end


Good luck!
Bruno

On Wed, Sep 2, 2009 at 7:57 AM, jim <[email protected]> wrote:

>
> Hi!
>
> If I override a validation, for example in Photo.rb, the errors are
> duplicated (seems that validation is passed twice, one in the plugin
> and one in the app).  Is this the correct behavior or is there any way
> to override validations without the errors duplicating?
>
> Thanks!
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to