Commit b3291a5c by Jack Danger Canty Committed by Martin Stannard

reimplementing the good parts of a7e0b8cb

A class named Approval in moderations/approval.rb raises no error Signed-off-by: 's avatarctran <ctran@pragmaquest.com>
parent 7e5260c3
......@@ -159,7 +159,13 @@ module AnnotateModels
# Check for namespaced models in subdirectories as well as models
# in subdirectories without namespacing.
def get_model_class(file)
file.gsub(/\.rb$/, '').camelize.constantize
model = file.gsub(/\.rb$/, '').camelize
parts = model.split('::')
begin
parts.inject(Object) {|klass, part| klass.const_get(part) }
rescue LoadError
Object.const_get(parts.last)
end
end
# We're passed a name of things that might be
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment