squash this commit - check if model has #name
squash this commit - workaround for define_singleton_method not in 1.8.7