customer
モデルとがあるaccount
としましょうaddress
:
class Customer
has_many :accounts
end
class Account
belongs_to :customer
has_many :addresses
end
class Address
belongs_to :account
end
オブジェクト アドレスが与えられると、その顧客は次のように取得できます。
customer = address.account.customer
関係を文字列変数に格納しましょうaddress_relation = 'account.customer'
。オブジェクトが与えられた場合、次のような文字列変数address
を使用して取得する方法はありますか?customer
address_relation
customer = address.address_relation
?
助けてくれてありがとう。