diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-16 02:06:11 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-16 02:06:11 +0000 |
commit | 8bc82278dddfe23d84ac24ffe83f92c816028dd8 (patch) | |
tree | 4174fff5d299c9d6f8916eae0ab144d21ab55e02 /actionpack/lib/action_controller/dependencies.rb | |
parent | 1579f3b45db4b5717984174689c41b1e7f679d1b (diff) | |
download | rails-8bc82278dddfe23d84ac24ffe83f92c816028dd8.tar.gz rails-8bc82278dddfe23d84ac24ffe83f92c816028dd8.tar.bz2 rails-8bc82278dddfe23d84ac24ffe83f92c816028dd8.zip |
Added that controllers will now attempt to require a model dependency with their name and in a singular attempt for their name.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@175 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack/lib/action_controller/dependencies.rb')
-rw-r--r-- | actionpack/lib/action_controller/dependencies.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/dependencies.rb b/actionpack/lib/action_controller/dependencies.rb index 5a3dd48f89..6680d6cffd 100644 --- a/actionpack/lib/action_controller/dependencies.rb +++ b/actionpack/lib/action_controller/dependencies.rb @@ -15,6 +15,8 @@ module ActionController #:nodoc: cattr_accessor :reload_dependencies end + base.class_eval { class << self; alias_method :inherited_without_model, :inherited; end } + base.extend(ClassMethods) end @@ -62,6 +64,16 @@ module ActionController #:nodoc: end end end + + def inherited(child) + inherited_without_model(child) + begin + child.model(child.controller_name) + child.model(Inflector.singularize(child.controller_name)) + rescue LoadError + # No neither singular or plural model available for this controller + end + end end end end |