aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorYves Senn <yves.senn@garaio.com>2011-05-20 16:48:51 +0200
committerYves Senn <yves.senn@garaio.com>2011-05-20 16:59:09 +0200
commite5429b789db242950c39215b4e154bbc73034a28 (patch)
treee1979d7e05c8eeef558439b0fa163e66934e47fd /activemodel/lib
parent499825e19f961569d6ee72ca4b7e9d6b79164085 (diff)
downloadrails-e5429b789db242950c39215b4e154bbc73034a28.tar.gz
rails-e5429b789db242950c39215b4e154bbc73034a28.tar.bz2
rails-e5429b789db242950c39215b4e154bbc73034a28.zip
Specify the name to be used for ActiveModel::Name fixes #1168
This patch allows to specify the name of your models independent of the class name.
Diffstat (limited to 'activemodel/lib')
-rw-r--r--activemodel/lib/active_model/naming.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/naming.rb b/activemodel/lib/active_model/naming.rb
index 74708692af..4c1a82f413 100644
--- a/activemodel/lib/active_model/naming.rb
+++ b/activemodel/lib/active_model/naming.rb
@@ -7,8 +7,9 @@ module ActiveModel
attr_reader :singular, :plural, :element, :collection, :partial_path, :route_key, :param_key, :i18n_key
alias_method :cache_key, :collection
- def initialize(klass, namespace = nil)
- super(klass.name)
+ def initialize(klass, namespace = nil, name = nil)
+ name ||= klass.name
+ super(name)
@unnamespaced = self.sub(/^#{namespace.name}::/, '') if namespace
@klass = klass