How can I get the attribute from the model object dynamically? I have the attribute of the User object as string:
u = User.find(1)
Can I do something like u.get("user_id")
How can I get the attribute from the model object dynamically? I have the attribute of the User object as string:
u = User.find(1)
Can I do something like u.get("user_id")
Try this
then something like this should do what you require
Not sure if I totally understand your questions. Try something like:
if you mean you only want to fetch from DB specific attribute you can do:
You could try using the ActiveRecord model instance like a hash.
Yet another approach:
Try this