diff options
author | Jacek Becela <jacek.becela@gmail.com> | 2008-05-08 13:47:24 +0200 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2008-05-10 11:28:19 +0100 |
commit | a7ea06b4ebe252e258f83e7de945b4baa30ec3bc (patch) | |
tree | 8c4022c3395dd485681cb40407ed3cdd7414c646 /actionpack/lib/action_controller | |
parent | 6776edccf6fb553eb0ac6db55e1d30df1b5b6589 (diff) | |
download | rails-a7ea06b4ebe252e258f83e7de945b4baa30ec3bc.tar.gz rails-a7ea06b4ebe252e258f83e7de945b4baa30ec3bc.tar.bz2 rails-a7ea06b4ebe252e258f83e7de945b4baa30ec3bc.zip |
Make render shorthands work with namespaced controllers
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/record_identifier.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index 22dbc8bbc5..643ff7e5f4 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -33,11 +33,17 @@ module ActionController # Returns plural/singular for a record or class. Example: # - # partial_path(post) # => "posts/post" - # partial_path(Person) # => "people/person" - def partial_path(record_or_class) + # partial_path(post) # => "posts/post" + # partial_path(Person) # => "people/person" + # partial_path(Person, "admin/games") # => "admin/people/person" + def partial_path(record_or_class, controller_path = nil) klass = class_from_record_or_class(record_or_class) - "#{klass.name.tableize}/#{klass.name.demodulize.underscore}" + + if controller_path && controller_path.include?("/") + "#{File.dirname(controller_path)}/#{klass.name.tableize}/#{klass.name.demodulize.underscore}" + else + "#{klass.name.tableize}/#{klass.name.demodulize.underscore}" + end end # The DOM class convention is to use the singular form of an object or class. Examples: |