mercredi 20 juillet 2016

Call dependencies using string formatted object

Is there a way to call dependencies in a string format?

Here are my models:

User

has_many :addresses

Address

belongs_to :user

And here is I am trying to do. I want do get all addresses of specific user and I want "addresses" to be a string because I want to make it dynamic. For example, I want to change "some_models_related_to_user".

user."addresses".first

Thanks!

Aucun commentaire:

Enregistrer un commentaire