From dc39af0a9a998938a969b214554db624dcdd9c85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ku=C5=BAma?= Date: Thu, 24 Nov 2011 15:50:21 +0100 Subject: make ActiveModel::Name fail gracefully with anonymous classes --- activemodel/lib/active_model/naming.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'activemodel/lib') diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb index 2566920d63..953d24a3b2 100644 --- a/activemodel/lib/active_model/naming.rb +++ b/activemodel/lib/active_model/naming.rb @@ -12,6 +12,9 @@ module ActiveModel def initialize(klass, namespace = nil, name = nil) name ||= klass.name + + raise ArgumentError, "Class name cannot be blank. You need to supply a name argument when anonymous class given" if name.blank? + super(name) @unnamespaced = self.sub(/^#{namespace.name}::/, '') if namespace -- cgit v1.2.3