Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed the application_controller require_dependency path generated by…

… the app generator
  • Loading branch information...
commit 686966a1861e6761021d45f6795de753e8a62216 1 parent 870310d
@fredwu fredwu authored
View
9 railties/lib/rails/generators/named_base.rb
@@ -84,10 +84,11 @@ def namespaced_file_path
end
def namespaced_class_path
- @namespaced_class_path ||= begin
- namespace_path = namespace.name.split("::").map {|m| m.underscore }
- namespace_path + @class_path
- end
+ @namespaced_class_path ||= [namespace_path] + @class_path
+ end
+
+ def namespace_path
+ @namespace_path ||= namespace.name.split("::").map {|m| m.underscore }[0]
end
def class_name
View
2  railties/lib/rails/generators/rails/controller/templates/controller.rb
@@ -1,5 +1,5 @@
<% if namespaced? -%>
-require_dependency "<%= namespaced_file_path %>/application_controller"
+require_dependency "<%= namespace_path %>/application_controller"
<% end -%>
<% module_namespacing do -%>
View
4 railties/test/generators/namespaced_generators_test.rb
@@ -38,7 +38,9 @@ def test_skipping_namespace
def test_namespaced_controller_with_additional_namespace
run_generator ["admin/account"]
- assert_file "app/controllers/test_app/admin/account_controller.rb", /module TestApp/, / class Admin::AccountController < ApplicationController/
+ assert_file "app/controllers/test_app/admin/account_controller.rb", /module TestApp/, / class Admin::AccountController < ApplicationController/ do |contents|
+ assert_match %r(require_dependency "test_app/application_controller"), contents
+ end
end
def test_helpr_is_also_namespaced
Please sign in to comment.
Something went wrong with that request. Please try again.