aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2012-05-22 01:40:51 -0700
committerPiotr Sarnacki <drogus@gmail.com>2012-05-22 01:47:08 -0700
commit56b86a377a9fa7d63a6fce1e5801c4910dfc703e (patch)
tree7ccf24faa375b0ec6f520db412ca1cddb1f75d6b /railties
parent5d6cca1d649d370cbb08b88c4af9008edd35b04b (diff)
downloadrails-56b86a377a9fa7d63a6fce1e5801c4910dfc703e.tar.gz
rails-56b86a377a9fa7d63a6fce1e5801c4910dfc703e.tar.bz2
rails-56b86a377a9fa7d63a6fce1e5801c4910dfc703e.zip
Use require_dependency in generated controllers
Using require in development mode will prevent required files from reloading, even if they're changed. In order to keep namespaced application_controller reloadable, we need to use require_dependency instead of require.
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/rails/controller/templates/controller.rb2
-rw-r--r--railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb2
-rw-r--r--railties/test/generators/namespaced_generators_test.rb4
3 files changed, 4 insertions, 4 deletions
diff --git a/railties/lib/rails/generators/rails/controller/templates/controller.rb b/railties/lib/rails/generators/rails/controller/templates/controller.rb
index 9b04192126..ece6bbba3b 100644
--- a/railties/lib/rails/generators/rails/controller/templates/controller.rb
+++ b/railties/lib/rails/generators/rails/controller/templates/controller.rb
@@ -1,5 +1,5 @@
<% if namespaced? -%>
-require "<%= namespaced_file_path %>/application_controller"
+require_dependency "<%= namespaced_file_path %>/application_controller"
<% end -%>
<% module_namespacing do -%>
diff --git a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
index dc0f5a0b3b..593c8d85e6 100644
--- a/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
+++ b/railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
@@ -1,5 +1,5 @@
<% if namespaced? -%>
-require "<%= namespaced_file_path %>/application_controller"
+require_dependency "<%= namespaced_file_path %>/application_controller"
<% end -%>
<% module_namespacing do -%>
diff --git a/railties/test/generators/namespaced_generators_test.rb b/railties/test/generators/namespaced_generators_test.rb
index cb88474ef1..88415b20e4 100644
--- a/railties/test/generators/namespaced_generators_test.rb
+++ b/railties/test/generators/namespaced_generators_test.rb
@@ -21,7 +21,7 @@ class NamespacedControllerGeneratorTest < NamespacedGeneratorTestCase
def test_namespaced_controller_skeleton_is_created
run_generator
assert_file "app/controllers/test_app/account_controller.rb",
- /require "test_app\/application_controller"/,
+ /require_dependency "test_app\/application_controller"/,
/module TestApp/,
/ class AccountController < ApplicationController/
@@ -229,7 +229,7 @@ class NamespacedScaffoldGeneratorTest < NamespacedGeneratorTestCase
# Controller
assert_file "app/controllers/test_app/product_lines_controller.rb",
- /require "test_app\/application_controller"/,
+ /require_dependency "test_app\/application_controller"/,
/module TestApp/,
/class ProductLinesController < ApplicationController/