Hello.
I'm facing the problem where I have something like this: class Person has_many :things, :conditions => "dynamic conditions depending of the object" end
So, the problem is that i would like to have a dynamic condition which depends upon the object. In my particular case, it is something like this: has_many :things, :conditions => {:country_code => 'country_code_string'}
So, let's say that the country_code_string might be 'UK', 'US' and so on. How can I make this kind of association? I tried lambda, like i could use in before_add, after_add and other callbacks, but then it seems that Proc object's string representation is used in WHERE clause. Is there even possible to have such thing or should i use something like: has_many :thingsUS, :conditions => {:country_code => 'US'} has_many :thingsUK, :conditions => {:country_code => 'UK'} ...
It doesn't feel much of an elegant solution to me. Better ideas how to solve this problem?
Jarmo