Created
June 25, 2012 13:11
-
-
Save kaorukobo/2988479 to your computer and use it in GitHub Desktop.
Hack for ActiveRecord: to avoid "NameError: uninitialized constant" on Rails-3.1.3 + active_scaffold 3.* (append parent module name to association's class_name)
This file contains 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
class ActiveRecord::Reflection::AssociationReflection | |
def derive_class_name | |
cn = "" | |
parent = active_record.parent | |
unless parent == Object | |
cn << "#{parent.name}::" | |
end | |
cn << name.to_s.camelize | |
cn = cn.singularize if collection? | |
cn | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"NameError: uninitialized constant" on Rails-3.1.3 + active_scaffold 3.*": https://gist.github.com/1663895