rails 2.2.3 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rails might be problematic. Click here for more details.

Files changed (229) hide show
  1. data/CHANGELOG +272 -191
  2. data/MIT-LICENSE +1 -1
  3. data/README +6 -19
  4. data/Rakefile +24 -71
  5. data/bin/rails +1 -0
  6. data/builtin/rails_info/rails/info.rb +12 -8
  7. data/configs/databases/mysql.yml +3 -0
  8. data/configs/initializers/backtrace_silencers.rb +7 -0
  9. data/configs/initializers/new_rails_defaults.rb +2 -0
  10. data/configs/initializers/session_store.rb +15 -0
  11. data/dispatches/config.ru +7 -0
  12. data/doc/README_FOR_APP +2 -5
  13. data/environments/boot.rb +1 -0
  14. data/environments/environment.rb +14 -48
  15. data/environments/production.rb +11 -7
  16. data/environments/test.rb +6 -0
  17. data/helpers/application_controller.rb +10 -0
  18. data/helpers/test_helper.rb +1 -1
  19. data/html/500.html +0 -3
  20. data/html/index.html +1 -0
  21. data/lib/commands/about.rb +1 -1
  22. data/lib/commands/dbconsole.rb +18 -2
  23. data/lib/commands/plugin.rb +4 -3
  24. data/lib/commands/runner.rb +13 -7
  25. data/lib/commands/server.rb +98 -33
  26. data/lib/console_app.rb +4 -4
  27. data/lib/console_with_helpers.rb +2 -23
  28. data/lib/dispatcher.rb +1 -1
  29. data/lib/fcgi_handler.rb +12 -10
  30. data/lib/initializer.rb +108 -41
  31. data/lib/rails/backtrace_cleaner.rb +54 -0
  32. data/lib/rails/gem_dependency.rb +124 -94
  33. data/lib/rails/plugin.rb +49 -6
  34. data/lib/rails/plugin/loader.rb +66 -27
  35. data/lib/rails/plugin/locator.rb +1 -1
  36. data/lib/rails/rack.rb +3 -1
  37. data/lib/rails/rack/debugger.rb +21 -0
  38. data/lib/rails/rack/log_tailer.rb +35 -0
  39. data/lib/rails/rack/metal.rb +51 -0
  40. data/lib/rails/rack/static.rb +15 -4
  41. data/lib/rails/version.rb +2 -2
  42. data/lib/rails_generator/base.rb +3 -0
  43. data/lib/rails_generator/commands.rb +8 -3
  44. data/lib/rails_generator/generators/applications/app/app_generator.rb +210 -136
  45. data/lib/rails_generator/generators/applications/app/scm/git.rb +16 -0
  46. data/lib/rails_generator/generators/applications/app/scm/scm.rb +8 -0
  47. data/lib/rails_generator/generators/applications/app/scm/svn.rb +7 -0
  48. data/lib/rails_generator/generators/applications/app/template_runner.rb +401 -0
  49. data/lib/rails_generator/generators/components/controller/USAGE +12 -11
  50. data/lib/rails_generator/generators/components/controller/controller_generator.rb +7 -1
  51. data/lib/rails_generator/generators/components/controller/templates/helper_test.rb +4 -0
  52. data/lib/rails_generator/generators/components/helper/USAGE +24 -0
  53. data/lib/rails_generator/generators/components/helper/helper_generator.rb +25 -0
  54. data/lib/rails_generator/generators/components/helper/templates/helper.rb +2 -0
  55. data/lib/rails_generator/generators/components/helper/templates/helper_test.rb +4 -0
  56. data/lib/rails_generator/generators/components/metal/USAGE +8 -0
  57. data/lib/rails_generator/generators/components/metal/metal_generator.rb +8 -0
  58. data/lib/rails_generator/generators/components/metal/templates/metal.rb +12 -0
  59. data/lib/rails_generator/generators/components/resource/USAGE +2 -2
  60. data/lib/rails_generator/generators/components/resource/resource_generator.rb +2 -0
  61. data/lib/rails_generator/generators/components/resource/templates/helper_test.rb +4 -0
  62. data/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +2 -0
  63. data/lib/rails_generator/generators/components/scaffold/templates/controller.rb +1 -1
  64. data/lib/rails_generator/generators/components/scaffold/templates/functional_test.rb +4 -4
  65. data/lib/rails_generator/generators/components/scaffold/templates/helper_test.rb +4 -0
  66. data/lib/rails_generator/generators/components/scaffold/templates/layout.html.erb +1 -1
  67. data/lib/rails_generator/generators/components/scaffold/templates/view_edit.html.erb +2 -2
  68. data/lib/rails_generator/generators/components/scaffold/templates/view_index.html.erb +2 -2
  69. data/lib/rails_generator/generators/components/scaffold/templates/view_new.html.erb +2 -2
  70. data/lib/rails_generator/generators/components/scaffold/templates/view_show.html.erb +1 -1
  71. data/lib/rails_generator/secret_key_generator.rb +2 -0
  72. data/lib/tasks/databases.rake +13 -6
  73. data/lib/tasks/documentation.rake +2 -9
  74. data/lib/tasks/framework.rake +26 -1
  75. data/lib/tasks/gems.rake +33 -48
  76. data/lib/tasks/middleware.rake +7 -0
  77. data/lib/tasks/misc.rake +7 -0
  78. data/lib/tasks/statistics.rake +0 -1
  79. data/lib/tasks/testing.rake +5 -5
  80. data/lib/tasks/tmp.rake +2 -2
  81. data/lib/test_help.rb +16 -8
  82. metadata +92 -159
  83. data/bin/performance/request +0 -3
  84. data/bin/process/inspector +0 -3
  85. data/bin/process/reaper +0 -3
  86. data/bin/process/spawner +0 -3
  87. data/config.ru +0 -17
  88. data/configs/apache.conf +0 -40
  89. data/configs/lighttpd.conf +0 -54
  90. data/doc/guides/html/2_2_release_notes.html +0 -1185
  91. data/doc/guides/html/actioncontroller_basics.html +0 -1270
  92. data/doc/guides/html/activerecord_validations_callbacks.html +0 -749
  93. data/doc/guides/html/association_basics.html +0 -2585
  94. data/doc/guides/html/authors.html +0 -240
  95. data/doc/guides/html/benchmarking_and_profiling.html +0 -1018
  96. data/doc/guides/html/caching_with_rails.html +0 -583
  97. data/doc/guides/html/command_line.html +0 -434
  98. data/doc/guides/html/configuring.html +0 -438
  99. data/doc/guides/html/creating_plugins.html +0 -1594
  100. data/doc/guides/html/debugging_rails_applications.html +0 -1175
  101. data/doc/guides/html/finders.html +0 -1090
  102. data/doc/guides/html/form_helpers.html +0 -638
  103. data/doc/guides/html/getting_started_with_rails.html +0 -2066
  104. data/doc/guides/html/index.html +0 -349
  105. data/doc/guides/html/layouts_and_rendering.html +0 -1406
  106. data/doc/guides/html/migrations.html +0 -921
  107. data/doc/guides/html/routing_outside_in.html +0 -2213
  108. data/doc/guides/html/security.html +0 -1346
  109. data/doc/guides/html/testing_rails_applications.html +0 -1859
  110. data/doc/guides/source/2_2_release_notes.txt +0 -435
  111. data/doc/guides/source/actioncontroller_basics/changelog.txt +0 -5
  112. data/doc/guides/source/actioncontroller_basics/cookies.txt +0 -34
  113. data/doc/guides/source/actioncontroller_basics/csrf.txt +0 -32
  114. data/doc/guides/source/actioncontroller_basics/filters.txt +0 -119
  115. data/doc/guides/source/actioncontroller_basics/http_auth.txt +0 -24
  116. data/doc/guides/source/actioncontroller_basics/index.txt +0 -40
  117. data/doc/guides/source/actioncontroller_basics/introduction.txt +0 -9
  118. data/doc/guides/source/actioncontroller_basics/methods.txt +0 -39
  119. data/doc/guides/source/actioncontroller_basics/parameter_filtering.txt +0 -14
  120. data/doc/guides/source/actioncontroller_basics/params.txt +0 -93
  121. data/doc/guides/source/actioncontroller_basics/request_response_objects.txt +0 -43
  122. data/doc/guides/source/actioncontroller_basics/rescue.txt +0 -67
  123. data/doc/guides/source/actioncontroller_basics/session.txt +0 -187
  124. data/doc/guides/source/actioncontroller_basics/streaming.txt +0 -91
  125. data/doc/guides/source/actioncontroller_basics/verification.txt +0 -40
  126. data/doc/guides/source/active_record_basics.txt +0 -181
  127. data/doc/guides/source/activerecord_validations_callbacks.txt +0 -404
  128. data/doc/guides/source/association_basics.txt +0 -1840
  129. data/doc/guides/source/authors.txt +0 -39
  130. data/doc/guides/source/benchmarking_and_profiling/appendix.txt +0 -95
  131. data/doc/guides/source/benchmarking_and_profiling/digging_deeper.txt +0 -105
  132. data/doc/guides/source/benchmarking_and_profiling/edge_rails_features.txt +0 -185
  133. data/doc/guides/source/benchmarking_and_profiling/gameplan.txt +0 -27
  134. data/doc/guides/source/benchmarking_and_profiling/index.txt +0 -242
  135. data/doc/guides/source/benchmarking_and_profiling/rubyprof.txt +0 -179
  136. data/doc/guides/source/benchmarking_and_profiling/statistics.txt +0 -57
  137. data/doc/guides/source/caching_with_rails.txt +0 -367
  138. data/doc/guides/source/command_line.txt +0 -147
  139. data/doc/guides/source/configuring.txt +0 -225
  140. data/doc/guides/source/creating_plugins/acts_as_yaffle.txt +0 -191
  141. data/doc/guides/source/creating_plugins/appendix.txt +0 -46
  142. data/doc/guides/source/creating_plugins/controllers.txt +0 -59
  143. data/doc/guides/source/creating_plugins/core_ext.txt +0 -123
  144. data/doc/guides/source/creating_plugins/custom_route.txt +0 -69
  145. data/doc/guides/source/creating_plugins/gem.txt +0 -1
  146. data/doc/guides/source/creating_plugins/generator_method.txt +0 -89
  147. data/doc/guides/source/creating_plugins/helpers.txt +0 -51
  148. data/doc/guides/source/creating_plugins/index.txt +0 -52
  149. data/doc/guides/source/creating_plugins/migration_generator.txt +0 -156
  150. data/doc/guides/source/creating_plugins/models.txt +0 -76
  151. data/doc/guides/source/creating_plugins/odds_and_ends.txt +0 -69
  152. data/doc/guides/source/creating_plugins/test_setup.txt +0 -230
  153. data/doc/guides/source/debugging_rails_applications.txt +0 -733
  154. data/doc/guides/source/finders.txt +0 -668
  155. data/doc/guides/source/form_helpers.txt +0 -345
  156. data/doc/guides/source/getting_started_with_rails.txt +0 -1256
  157. data/doc/guides/source/images/belongs_to.png +0 -0
  158. data/doc/guides/source/images/bullet.gif +0 -0
  159. data/doc/guides/source/images/csrf.png +0 -0
  160. data/doc/guides/source/images/habtm.png +0 -0
  161. data/doc/guides/source/images/has_many.png +0 -0
  162. data/doc/guides/source/images/has_many_through.png +0 -0
  163. data/doc/guides/source/images/has_one.png +0 -0
  164. data/doc/guides/source/images/has_one_through.png +0 -0
  165. data/doc/guides/source/images/header_backdrop.png +0 -0
  166. data/doc/guides/source/images/icons/README +0 -5
  167. data/doc/guides/source/images/icons/callouts/1.png +0 -0
  168. data/doc/guides/source/images/icons/callouts/10.png +0 -0
  169. data/doc/guides/source/images/icons/callouts/11.png +0 -0
  170. data/doc/guides/source/images/icons/callouts/12.png +0 -0
  171. data/doc/guides/source/images/icons/callouts/13.png +0 -0
  172. data/doc/guides/source/images/icons/callouts/14.png +0 -0
  173. data/doc/guides/source/images/icons/callouts/15.png +0 -0
  174. data/doc/guides/source/images/icons/callouts/2.png +0 -0
  175. data/doc/guides/source/images/icons/callouts/3.png +0 -0
  176. data/doc/guides/source/images/icons/callouts/4.png +0 -0
  177. data/doc/guides/source/images/icons/callouts/5.png +0 -0
  178. data/doc/guides/source/images/icons/callouts/6.png +0 -0
  179. data/doc/guides/source/images/icons/callouts/7.png +0 -0
  180. data/doc/guides/source/images/icons/callouts/8.png +0 -0
  181. data/doc/guides/source/images/icons/callouts/9.png +0 -0
  182. data/doc/guides/source/images/icons/caution.png +0 -0
  183. data/doc/guides/source/images/icons/example.png +0 -0
  184. data/doc/guides/source/images/icons/home.png +0 -0
  185. data/doc/guides/source/images/icons/important.png +0 -0
  186. data/doc/guides/source/images/icons/next.png +0 -0
  187. data/doc/guides/source/images/icons/note.png +0 -0
  188. data/doc/guides/source/images/icons/prev.png +0 -0
  189. data/doc/guides/source/images/icons/tip.png +0 -0
  190. data/doc/guides/source/images/icons/up.png +0 -0
  191. data/doc/guides/source/images/icons/warning.png +0 -0
  192. data/doc/guides/source/images/polymorphic.png +0 -0
  193. data/doc/guides/source/images/rails_logo_remix.gif +0 -0
  194. data/doc/guides/source/images/ruby_on_rails_by_mike_rundle2.gif +0 -0
  195. data/doc/guides/source/images/session_fixation.png +0 -0
  196. data/doc/guides/source/index.txt +0 -118
  197. data/doc/guides/source/layouts_and_rendering.txt +0 -982
  198. data/doc/guides/source/migrations/anatomy_of_a_migration.txt +0 -85
  199. data/doc/guides/source/migrations/changelog.txt +0 -5
  200. data/doc/guides/source/migrations/creating_a_migration.txt +0 -109
  201. data/doc/guides/source/migrations/foreign_keys.txt +0 -8
  202. data/doc/guides/source/migrations/index.txt +0 -22
  203. data/doc/guides/source/migrations/rakeing_around.txt +0 -111
  204. data/doc/guides/source/migrations/scheming.txt +0 -47
  205. data/doc/guides/source/migrations/using_models_in_migrations.txt +0 -46
  206. data/doc/guides/source/migrations/writing_a_migration.txt +0 -159
  207. data/doc/guides/source/routing_outside_in.txt +0 -986
  208. data/doc/guides/source/security.txt +0 -984
  209. data/doc/guides/source/stylesheets/base.css +0 -358
  210. data/doc/guides/source/stylesheets/forms.css +0 -35
  211. data/doc/guides/source/stylesheets/more.css +0 -82
  212. data/doc/guides/source/templates/guides.html.erb +0 -97
  213. data/doc/guides/source/templates/inline.css +0 -165
  214. data/doc/guides/source/testing_rails_applications.txt +0 -995
  215. data/helpers/application.rb +0 -15
  216. data/lib/commands/performance/request.rb +0 -6
  217. data/lib/commands/process/inspector.rb +0 -68
  218. data/lib/commands/process/reaper.rb +0 -149
  219. data/lib/commands/process/spawner.rb +0 -219
  220. data/lib/commands/process/spinner.rb +0 -57
  221. data/lib/commands/servers/base.rb +0 -31
  222. data/lib/commands/servers/lighttpd.rb +0 -94
  223. data/lib/commands/servers/mongrel.rb +0 -69
  224. data/lib/commands/servers/new_mongrel.rb +0 -16
  225. data/lib/commands/servers/thin.rb +0 -25
  226. data/lib/commands/servers/webrick.rb +0 -66
  227. data/lib/rails/mongrel_server/commands.rb +0 -342
  228. data/lib/rails/mongrel_server/handler.rb +0 -55
  229. data/lib/rails/rack/logger.rb +0 -28
@@ -2,13 +2,14 @@ class ControllerGenerator < Rails::Generator::NamedBase
2
2
  def manifest
3
3
  record do |m|
4
4
  # Check for class naming collisions.
5
- m.class_collisions "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
5
+ m.class_collisions "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper", "#{class_name}HelperTest"
6
6
 
7
7
  # Controller, helper, views, and test directories.
8
8
  m.directory File.join('app/controllers', class_path)
9
9
  m.directory File.join('app/helpers', class_path)
10
10
  m.directory File.join('app/views', class_path, file_name)
11
11
  m.directory File.join('test/functional', class_path)
12
+ m.directory File.join('test/unit/helpers', class_path)
12
13
 
13
14
  # Controller class, functional test, and helper class.
14
15
  m.template 'controller.rb',
@@ -26,6 +27,11 @@ class ControllerGenerator < Rails::Generator::NamedBase
26
27
  class_path,
27
28
  "#{file_name}_helper.rb")
28
29
 
30
+ m.template 'helper_test.rb',
31
+ File.join('test/unit/helpers',
32
+ class_path,
33
+ "#{file_name}_helper_test.rb")
34
+
29
35
  # View template for each action.
30
36
  actions.each do |action|
31
37
  path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,24 @@
1
+ Description:
2
+ Stubs out a new helper. Pass the helper name, either
3
+ CamelCased or under_scored.
4
+
5
+ To create a helper within a module, specify the helper name as a
6
+ path like 'parent_module/helper_name'.
7
+
8
+ This generates a helper class in app/helpers and a helper test
9
+ suite in test/unit/helpers.
10
+
11
+ Example:
12
+ `./script/generate helper CreditCard`
13
+
14
+ Credit card helper.
15
+ Helper: app/helpers/credit_card_helper.rb
16
+ Test: test/unit/helpers/credit_card_helper_test.rb
17
+
18
+ Modules Example:
19
+ `./script/generate helper 'admin/credit_card'`
20
+
21
+ Credit card admin helper.
22
+ Helper: app/helpers/admin/credit_card_helper.rb
23
+ Test: test/unit/helpers/admin/credit_card_helper_test.rb
24
+
@@ -0,0 +1,25 @@
1
+ class HelperGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ # Check for class naming collisions.
5
+ m.class_collisions class_path, "#{class_name}Helper", "#{class_name}HelperTest"
6
+
7
+ # Helper and helper test directories.
8
+ m.directory File.join('app/helpers', class_path)
9
+ m.directory File.join('test/unit/helpers', class_path)
10
+
11
+ # Helper and helper test class.
12
+
13
+ m.template 'helper.rb',
14
+ File.join('app/helpers',
15
+ class_path,
16
+ "#{file_name}_helper.rb")
17
+
18
+ m.template 'helper_test.rb',
19
+ File.join('test/unit/helpers',
20
+ class_path,
21
+ "#{file_name}_helper_test.rb")
22
+
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,2 @@
1
+ module <%= class_name %>Helper
2
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Cast some metal!
3
+
4
+ Examples:
5
+ `./script/generate metal poller`
6
+
7
+ This will create:
8
+ Metal: app/metal/poller.rb
@@ -0,0 +1,8 @@
1
+ class MetalGenerator < Rails::Generator::NamedBase
2
+ def manifest
3
+ record do |m|
4
+ m.directory 'app/metal'
5
+ m.template 'metal.rb', File.join('app/metal', "#{file_name}.rb")
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ # Allow the metal piece to run in isolation
2
+ require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails)
3
+
4
+ class <%= class_name %>
5
+ def self.call(env)
6
+ if env["PATH_INFO"] =~ /^\/<%= file_name %>/
7
+ [200, {"Content-Type" => "text/html"}, ["Hello, World!"]]
8
+ else
9
+ [404, {"Content-Type" => "text/html"}, ["Not Found"]]
10
+ end
11
+ end
12
+ end
@@ -11,8 +11,8 @@ Description:
11
11
  You don't have to think up every attribute up front, but it helps to
12
12
  sketch out a few so you can start working with the resource immediately.
13
13
 
14
- This creates a model, controller, tests and fixtures for both, and the
15
- corresponding map.resources declaration in config/routes.rb
14
+ This creates a model, controller, helper, tests and fixtures for all of them,
15
+ and the corresponding map.resources declaration in config/routes.rb
16
16
 
17
17
  Unlike the scaffold generator, the resource generator does not create
18
18
  views or add any methods to the generated controller.
@@ -40,6 +40,7 @@ class ResourceGenerator < Rails::Generator::NamedBase
40
40
  m.directory(File.join('app/views', controller_class_path, controller_file_name))
41
41
  m.directory(File.join('test/functional', controller_class_path))
42
42
  m.directory(File.join('test/unit', class_path))
43
+ m.directory(File.join('test/unit/helpers', class_path))
43
44
 
44
45
  m.dependency 'model', [name] + @args, :collision => :skip
45
46
 
@@ -49,6 +50,7 @@ class ResourceGenerator < Rails::Generator::NamedBase
49
50
 
50
51
  m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
51
52
  m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
53
+ m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
52
54
 
53
55
  m.route_resources controller_file_name
54
56
  end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -47,6 +47,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
47
47
  m.directory(File.join('app/views/layouts', controller_class_path))
48
48
  m.directory(File.join('test/functional', controller_class_path))
49
49
  m.directory(File.join('test/unit', class_path))
50
+ m.directory(File.join('test/unit/helpers', class_path))
50
51
  m.directory(File.join('public/stylesheets', class_path))
51
52
 
52
53
  for action in scaffold_views
@@ -66,6 +67,7 @@ class ScaffoldGenerator < Rails::Generator::NamedBase
66
67
 
67
68
  m.template('functional_test.rb', File.join('test/functional', controller_class_path, "#{controller_file_name}_controller_test.rb"))
68
69
  m.template('helper.rb', File.join('app/helpers', controller_class_path, "#{controller_file_name}_helper.rb"))
70
+ m.template('helper_test.rb', File.join('test/unit/helpers', controller_class_path, "#{controller_file_name}_helper_test.rb"))
69
71
 
70
72
  m.route_resources controller_file_name
71
73
 
@@ -2,7 +2,7 @@ class <%= controller_class_name %>Controller < ApplicationController
2
2
  # GET /<%= table_name %>
3
3
  # GET /<%= table_name %>.xml
4
4
  def index
5
- @<%= table_name %> = <%= class_name %>.find(:all)
5
+ @<%= table_name %> = <%= class_name %>.all
6
6
 
7
7
  respond_to do |format|
8
8
  format.html # index.html.erb
@@ -21,23 +21,23 @@ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
21
21
  end
22
22
 
23
23
  test "should show <%= file_name %>" do
24
- get :show, :id => <%= table_name %>(:one).id
24
+ get :show, :id => <%= table_name %>(:one).to_param
25
25
  assert_response :success
26
26
  end
27
27
 
28
28
  test "should get edit" do
29
- get :edit, :id => <%= table_name %>(:one).id
29
+ get :edit, :id => <%= table_name %>(:one).to_param
30
30
  assert_response :success
31
31
  end
32
32
 
33
33
  test "should update <%= file_name %>" do
34
- put :update, :id => <%= table_name %>(:one).id, :<%= file_name %> => { }
34
+ put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
35
35
  assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
36
36
  end
37
37
 
38
38
  test "should destroy <%= file_name %>" do
39
39
  assert_difference('<%= class_name %>.count', -1) do
40
- delete :destroy, :id => <%= table_name %>(:one).id
40
+ delete :destroy, :id => <%= table_name %>(:one).to_param
41
41
  end
42
42
 
43
43
  assert_redirected_to <%= table_name %>_path
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -11,7 +11,7 @@
11
11
 
12
12
  <p style="color: green"><%%= flash[:notice] %></p>
13
13
 
14
- <%%= yield %>
14
+ <%%= yield %>
15
15
 
16
16
  </body>
17
17
  </html>
@@ -10,9 +10,9 @@
10
10
  </p>
11
11
  <% end -%>
12
12
  <p>
13
- <%%= f.submit "Update" %>
13
+ <%%= f.submit 'Update' %>
14
14
  </p>
15
15
  <%% end %>
16
16
 
17
17
  <%%= link_to 'Show', @<%= singular_name %> %> |
18
- <%%= link_to 'Back', <%= plural_name %>_path %>
18
+ <%%= link_to 'Back', <%= plural_name %>_path %>
@@ -7,7 +7,7 @@
7
7
  <% end -%>
8
8
  </tr>
9
9
 
10
- <%% for <%= singular_name %> in @<%= plural_name %> %>
10
+ <%% @<%= plural_name %>.each do |<%= singular_name %>| %>
11
11
  <tr>
12
12
  <% for attribute in attributes -%>
13
13
  <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
@@ -21,4 +21,4 @@
21
21
 
22
22
  <br />
23
23
 
24
- <%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
24
+ <%%= link_to 'New <%= singular_name %>', new_<%= singular_name %>_path %>
@@ -10,8 +10,8 @@
10
10
  </p>
11
11
  <% end -%>
12
12
  <p>
13
- <%%= f.submit "Create" %>
13
+ <%%= f.submit 'Create' %>
14
14
  </p>
15
15
  <%% end %>
16
16
 
17
- <%%= link_to 'Back', <%= plural_name %>_path %>
17
+ <%%= link_to 'Back', <%= plural_name %>_path %>
@@ -7,4 +7,4 @@
7
7
  <% end -%>
8
8
 
9
9
  <%%= link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
10
- <%%= link_to 'Back', <%= plural_name %>_path %>
10
+ <%%= link_to 'Back', <%= plural_name %>_path %>
@@ -1,3 +1,5 @@
1
+ require 'active_support/deprecation'
2
+
1
3
  module Rails
2
4
  # A class for creating random secret keys. This class will do its best to create a
3
5
  # random secret key that's as secure as possible, using whatever methods are
@@ -1,7 +1,12 @@
1
1
  namespace :db do
2
+ task :load_config => :rails_env do
3
+ require 'active_record'
4
+ ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration
5
+ end
6
+
2
7
  namespace :create do
3
8
  desc 'Create all the local databases defined in config/database.yml'
4
- task :all => :environment do
9
+ task :all => :load_config do
5
10
  ActiveRecord::Base.configurations.each_value do |config|
6
11
  # Skip entries that don't have a database key, such as the first entry here:
7
12
  #
@@ -22,7 +27,7 @@ namespace :db do
22
27
  end
23
28
 
24
29
  desc 'Create the database defined in config/database.yml for the current RAILS_ENV'
25
- task :create => :environment do
30
+ task :create => :load_config do
26
31
  create_database(ActiveRecord::Base.configurations[RAILS_ENV])
27
32
  end
28
33
 
@@ -76,7 +81,7 @@ namespace :db do
76
81
 
77
82
  namespace :drop do
78
83
  desc 'Drops all the local databases defined in config/database.yml'
79
- task :all => :environment do
84
+ task :all => :load_config do
80
85
  ActiveRecord::Base.configurations.each_value do |config|
81
86
  # Skip entries that don't have a database key
82
87
  next unless config['database']
@@ -87,7 +92,7 @@ namespace :db do
87
92
  end
88
93
 
89
94
  desc 'Drops the database for the current RAILS_ENV'
90
- task :drop => :environment do
95
+ task :drop => :load_config do
91
96
  config = ActiveRecord::Base.configurations[RAILS_ENV || 'development']
92
97
  begin
93
98
  drop_database(config)
@@ -105,7 +110,7 @@ namespace :db do
105
110
  end
106
111
 
107
112
 
108
- desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
113
+ desc "Migrate the database through scripts in db/migrate and update db/schema.rb by invoking db:schema:dump. Target specific version with VERSION=x. Turn off output with VERBOSE=false."
109
114
  task :migrate => :environment do
110
115
  ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
111
116
  ActiveRecord::Migrator.migrate("db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
@@ -245,6 +250,7 @@ namespace :db do
245
250
  File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file|
246
251
  ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
247
252
  end
253
+ Rake::Task["db:schema:dump"].reenable
248
254
  end
249
255
 
250
256
  desc "Load a schema.rb file into the database"
@@ -375,7 +381,7 @@ namespace :db do
375
381
  end
376
382
 
377
383
  namespace :sessions do
378
- desc "Creates a sessions migration for use with CGI::Session::ActiveRecordStore"
384
+ desc "Creates a sessions migration for use with ActiveRecord::SessionStore"
379
385
  task :create => :environment do
380
386
  raise "Task unavailable to this database (no migration support)" unless ActiveRecord::Base.connection.supports_migrations?
381
387
  require 'rails_generator'
@@ -393,6 +399,7 @@ end
393
399
  def drop_database(config)
394
400
  case config['adapter']
395
401
  when 'mysql'
402
+ ActiveRecord::Base.establish_connection(config)
396
403
  ActiveRecord::Base.connection.drop_database config['database']
397
404
  when /^sqlite/
398
405
  FileUtils.rm(File.join(RAILS_ROOT, config['database']))
@@ -54,15 +54,8 @@ namespace :doc do
54
54
 
55
55
  desc "Generate Rails guides"
56
56
  task :guides do
57
- source = File.join(RAILTIES_PATH, "doc/guides")
58
- destination = File.join(RAILS_ROOT, "doc/guides")
59
- FileUtils.rm_r(destination) if File.directory?(destination)
60
- FileUtils.mkdir(destination)
61
-
62
- FileUtils.cp_r File.join(source, 'html/.'), File.join(destination)
63
- # Copy images and css files to html directory. These dirs are in .gitigore and shouldn't be source controlled.
64
- FileUtils.cp_r File.join(source, 'source/images'), File.join(destination)
65
- FileUtils.cp_r File.join(source, 'source/stylesheets'), File.join(destination, 'stylesheets')
57
+ require File.join(RAILTIES_PATH, "guides/rails_guides")
58
+ RailsGuides::Generator.new(File.join(RAILS_ROOT, "doc/guides")).generate
66
59
  end
67
60
 
68
61
  namespace :plugins do
@@ -78,7 +78,13 @@ namespace :rails do
78
78
  end
79
79
 
80
80
  desc "Update both configs, scripts and public/javascripts from Rails"
81
- task :update => [ "update:scripts", "update:javascripts", "update:configs" ]
81
+ task :update => [ "update:scripts", "update:javascripts", "update:configs", "update:application_controller" ]
82
+
83
+ desc "Applies the template supplied by LOCATION=/path/to/template"
84
+ task :template do
85
+ require 'rails_generator/generators/applications/app/template_runner'
86
+ Rails::TemplateRunner.new(ENV["LOCATION"])
87
+ end
82
88
 
83
89
  namespace :update do
84
90
  desc "Add new scripts to the application script/ directory"
@@ -114,5 +120,24 @@ namespace :rails do
114
120
  require 'railties_path'
115
121
  FileUtils.cp(RAILTIES_PATH + '/environments/boot.rb', RAILS_ROOT + '/config/boot.rb')
116
122
  end
123
+
124
+ desc "Rename application.rb to application_controller.rb"
125
+ task :application_controller do
126
+ old_style = RAILS_ROOT + '/app/controllers/application.rb'
127
+ new_style = RAILS_ROOT + '/app/controllers/application_controller.rb'
128
+ if File.exists?(old_style) && !File.exists?(new_style)
129
+ FileUtils.mv(old_style, new_style)
130
+ puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary"
131
+ end
132
+ end
133
+
134
+ desc "Generate dispatcher files in RAILS_ROOT/public"
135
+ task :generate_dispatchers do
136
+ require 'railties_path'
137
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/config.ru', RAILS_ROOT + '/config.ru')
138
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.fcgi', RAILS_ROOT + '/public/dispatch.fcgi')
139
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.rb')
140
+ FileUtils.cp(RAILTIES_PATH + '/dispatches/dispatch.rb', RAILS_ROOT + '/public/dispatch.cgi')
141
+ end
117
142
  end
118
143
  end
@@ -9,72 +9,57 @@ task :gems => 'gems:base' do
9
9
  puts "R = Framework (loaded before rails starts)"
10
10
  end
11
11
 
12
- def print_gem_status(gem, indent=1)
13
- code = gem.loaded? ? (gem.frozen? ? (gem.framework_gem? ? "R" : "F") : "I") : " "
14
- puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
15
- gem.dependencies.each { |g| print_gem_status(g, indent+1)} if gem.loaded?
16
- end
17
-
18
12
  namespace :gems do
19
13
  task :base do
20
- $rails_gem_installer = true
14
+ $gems_rake_task = true
15
+ require 'rubygems'
16
+ require 'rubygems/gem_runner'
21
17
  Rake::Task[:environment].invoke
22
18
  end
23
19
 
24
20
  desc "Build any native extensions for unpacked gems"
25
21
  task :build do
26
- $rails_gem_installer = true
27
- require 'rails/gem_builder'
28
- Dir[File.join(Rails::GemDependency.unpacked_path, '*')].each do |gem_dir|
29
- spec_file = File.join(gem_dir, '.specification')
30
- next unless File.exists?(spec_file)
31
- specification = YAML::load_file(spec_file)
32
- next unless ENV['GEM'].blank? || ENV['GEM'] == specification.name
33
- Rails::GemBuilder.new(specification, gem_dir).build_extensions
34
- puts "Built gem: '#{gem_dir}'"
35
- end
22
+ $gems_build_rake_task = true
23
+ Rake::Task['gems:unpack'].invoke
24
+ current_gems.each &:build
36
25
  end
37
26
 
38
- desc "Installs all required gems for this application."
27
+ desc "Installs all required gems."
39
28
  task :install => :base do
40
- require 'rubygems'
41
- require 'rubygems/gem_runner'
42
- Rails.configuration.gems.each { |gem| gem.install unless gem.loaded? }
29
+ current_gems.each &:install
43
30
  end
44
31
 
45
- desc "Unpacks the specified gem into vendor/gems."
46
- task :unpack => :base do
47
- require 'rubygems'
48
- require 'rubygems/gem_runner'
49
- Rails.configuration.gems.each do |gem|
50
- next unless !gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
51
- gem.unpack_to(Rails::GemDependency.unpacked_path) if gem.loaded?
52
- end
32
+ desc "Unpacks all required gems into vendor/gems."
33
+ task :unpack => :install do
34
+ current_gems.each &:unpack
53
35
  end
54
36
 
55
37
  namespace :unpack do
56
- desc "Unpacks the specified gems and its dependencies into vendor/gems"
57
- task :dependencies => :unpack do
58
- require 'rubygems'
59
- require 'rubygems/gem_runner'
60
- Rails.configuration.gems.each do |gem|
61
- next unless ENV['GEM'].blank? || ENV['GEM'] == gem.name
62
- gem.dependencies.each do |dependency|
63
- next if dependency.frozen?
64
- dependency.unpack_to(Rails::GemDependency.unpacked_path)
65
- end
66
- end
38
+ desc "Unpacks all required gems and their dependencies into vendor/gems."
39
+ task :dependencies => :install do
40
+ current_gems.each { |gem| gem.unpack(:recursive => true) }
67
41
  end
68
42
  end
69
43
 
70
44
  desc "Regenerate gem specifications in correct format."
71
45
  task :refresh_specs => :base do
72
- require 'rubygems'
73
- require 'rubygems/gem_runner'
74
- Rails::VendorGemSourceIndex.silence_spec_warnings = true
75
- Rails.configuration.gems.each do |gem|
76
- next unless gem.frozen? && (ENV['GEM'].blank? || ENV['GEM'] == gem.name)
77
- gem.refresh_spec(Rails::GemDependency.unpacked_path) if gem.loaded?
78
- end
46
+ current_gems.each &:refresh
79
47
  end
80
- end
48
+ end
49
+
50
+ def current_gems
51
+ gems = Rails.configuration.gems
52
+ gems = gems.select { |gem| gem.name == ENV['GEM'] } unless ENV['GEM'].blank?
53
+ gems
54
+ end
55
+
56
+ def print_gem_status(gem, indent=1)
57
+ code = case
58
+ when gem.framework_gem? then 'R'
59
+ when gem.frozen? then 'F'
60
+ when gem.installed? then 'I'
61
+ else ' '
62
+ end
63
+ puts " "*(indent-1)+" - [#{code}] #{gem.name} #{gem.requirement.to_s}"
64
+ gem.dependencies.each { |g| print_gem_status(g, indent+1) }
65
+ end