Max Williams wrote:
> Hi Saurabh
> 
> Yes, it does seem that the "Answers is not valid" error message is 
> default, in the sense that nothing that i am doing is causing it, and 
> i'd like to remove it as you say.  The fact that the error message is 
> identical to what i would get from "validates_associated :answers" makes 
> me think it's something to do with that but i may be wrong.
> 
> The weird thing is that i don't usually get this in my other classes 
> that have has_many associations.  I also don't get it in this class for 
> the association with assets, which is also has_many.  For example. if i 
> invalidate an associated asset, or an associated question_asset (which 
> is the join between question and assets) then the question doesn't mind, 
> and is still valid.
> 
> So, it seems like a deviation from the normal behaviour.

Hi Max,

Have you tried the following in your model:

def after_validation
    # Skip errors that won't be useful to the end user
    filtered_errors = self.errors.reject{ |err| %w{ model name 
}.include?(err.first) }
    self.errors.clear
    filtered_errors.each { |err| self.errors.add(*err) }
  end

Hope this help.

Regards
Saurabh
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to