Created
August 6, 2013 20:50
-
-
Save tjhanley/6168509 to your computer and use it in GitHub Desktop.
Need a better way....
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def perform(user_id, class_name) | |
user = eval class_name + '.find(' + user_id.to_s + ')' | |
end |
So twitter just crapped out on me.
How about:
user = class_name.constantize.public_send(:find, user_id)
I suppose you don't actually need the public send, either.
class_name.constantize.find(user_id)
+1 on constantize
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
eval makes me feel oogy