I have a PaymentDetail model with attribute 'home_address_country', so i can use
@payment_detail.home_address_country //where @payment_detail is object of that model.
I want to use something like this:---
country_attribute=address_type+"_address_country" //where address type is equal to 'home'
@payment_detail."#{country_attribute}"
Means attribute name is stored in a variable. How can i do this?
EDIT
country_attribute=address_type+"_address_country"
country_list=Carmen::country_names
eval("@#{country_attribute} = #{country_list}")
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…