Ray Parker wrote in post #966033:
> I have an Account Model.  It has a polymorphic association to an
> Address model.  The Address model validates on what you'd expect, and
> the the issue comes about in the order of models and validations.
>
> We are trying to wedge functionality into an existing design without
> breaking a large system.

How's your test coverage?  If it's decent, you shouldn't need to worry 
about breaking the system, or about "wedging in" functionality.

(The idea of "wedging in" functionality is itself scary.  If something 
is worth doing, it's usually worth doing right, with all the refactoring 
that that implies.)

> The new requirement is that the address is
> only validated if a boolean column (is_admin_account) is false.

And which table is that field in?

(Style note: it's more Rubyish to leave the "is_" off the names of 
booleans.)

>
> Where I'm running into issue is that the Address model validates
> before the values are updated in the Account model and, based on the
> bool value, I want to validate or not.

So you want to validate the address, or not, depending on the contents 
of a field in an associated record in a different table?  That sounds 
really, really smelly to me.  I suspect it might be worth moving the 
validation flag into the addresses table.

If you can explain more about the structure of your data, I can probably 
be more helpful.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to