Instead of doing a if else statement. You can do "Answer".constantize to make it a class name. For example. "Answer".constantize.update_counters.........