TylerRick/active_record_ignored_attributes — Issue #1: What about  comparing assosications? 
Author: konung
Created: 2011-10-27 15:25:58+00:00
State: open

Hello.

Checking out your gem and it looks pretty good.

However I was wondering how would you go about comparing associations. Here is an example.

class Client
has_many :addresses, :as => :addressable, :include => :category, :dependent => :destroy
has_many :orders
validates_associated :addresses
validates_associated :orders
end

class Address
belongs_to :addressable, :polymorphic => true
end

class Discount
belongs_to :client
end

So consider these two cases:

Cient might have multiple addresses (shipping, billing, work, etc.), also if we introduce Warehouse model, it will need Addresses to - hence polymorphic association. So let's say I want to update a Client record. And the only thing that changed wasn't the actual client record, but the associated address ( let's say the zip code was wrong and I want to change that). How would I go about that

Case 2
Let's say each client can have 2 types of discounts: Personal & Corporate . I want to add a new discount to a client, but before I save it I need to make sure one doesn't exist already and if it does maybe all i need is just change the discount rate, instead of creating a new discount.