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
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/request'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/inspector'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/reaper'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/spawner'
data/config.ru DELETED
@@ -1,17 +0,0 @@
1
- # Rackup Configuration
2
- #
3
- # Start Rails mongrel server with rackup
4
- # $ rackup -p 3000 config.ru
5
- #
6
- # Start server with webrick (or any compatible Rack server) instead
7
- # $ rackup -p 3000 -s webrick config.ru
8
-
9
- # Require your environment file to bootstrap Rails
10
- require File.dirname(__FILE__) + '/config/environment'
11
-
12
- # Static server middleware
13
- # You can remove this extra check if you use an asset server
14
- use Rails::Rack::Static
15
-
16
- # Dispatch the request
17
- run ActionController::Dispatcher.new
@@ -1,40 +0,0 @@
1
- # General Apache options
2
- AddHandler fastcgi-script .fcgi
3
- AddHandler cgi-script .cgi
4
- Options +FollowSymLinks +ExecCGI
5
-
6
- # If you don't want Rails to look in certain directories,
7
- # use the following rewrite rules so that Apache won't rewrite certain requests
8
- #
9
- # Example:
10
- # RewriteCond %{REQUEST_URI} ^/notrails.*
11
- # RewriteRule .* - [L]
12
-
13
- # Redirect all requests not available on the filesystem to Rails
14
- # By default the cgi dispatcher is used which is very slow
15
- #
16
- # For better performance replace the dispatcher with the fastcgi one
17
- #
18
- # Example:
19
- # RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
20
- RewriteEngine On
21
-
22
- # If your Rails application is accessed via an Alias directive,
23
- # then you MUST also set the RewriteBase in this htaccess file.
24
- #
25
- # Example:
26
- # Alias /myrailsapp /path/to/myrailsapp/public
27
- # RewriteBase /myrailsapp
28
-
29
- RewriteRule ^$ index.html [QSA]
30
- RewriteRule ^([^.]+)$ $1.html [QSA]
31
- RewriteCond %{REQUEST_FILENAME} !-f
32
- RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
33
-
34
- # In case Rails experiences terminal errors
35
- # Instead of displaying this message you can supply a file here which will be rendered instead
36
- #
37
- # Example:
38
- # ErrorDocument 500 /500.html
39
-
40
- ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
@@ -1,54 +0,0 @@
1
- # Default configuration file for the lighttpd web server
2
- # Start using ./script/server lighttpd
3
-
4
- server.bind = "0.0.0.0"
5
- server.port = 3000
6
-
7
- server.modules = ( "mod_rewrite", "mod_accesslog", "mod_fastcgi", "mod_compress", "mod_expire" )
8
-
9
- server.error-handler-404 = "/dispatch.fcgi"
10
- server.pid-file = CWD + "/tmp/pids/lighttpd.pid"
11
- server.document-root = CWD + "/public/"
12
-
13
- server.errorlog = CWD + "/log/lighttpd.error.log"
14
- accesslog.filename = CWD + "/log/lighttpd.access.log"
15
-
16
- url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
17
-
18
- compress.filetype = ( "text/plain", "text/html", "text/css", "text/javascript" )
19
- compress.cache-dir = CWD + "/tmp/cache"
20
-
21
- expire.url = ( "/favicon.ico" => "access 3 days",
22
- "/images/" => "access 3 days",
23
- "/stylesheets/" => "access 3 days",
24
- "/javascripts/" => "access 3 days" )
25
-
26
-
27
- # Change *-procs to 2 if you need to use Upload Progress or other tasks that
28
- # *need* to execute a second request while the first is still pending.
29
- fastcgi.server = ( ".fcgi" => ( "localhost" => (
30
- "min-procs" => 1,
31
- "max-procs" => 1,
32
- "socket" => CWD + "/tmp/sockets/fcgi.socket",
33
- "bin-path" => CWD + "/public/dispatch.fcgi",
34
- "bin-environment" => ( "RAILS_ENV" => "development" )
35
- ) ) )
36
-
37
- mimetype.assign = (
38
- ".css" => "text/css",
39
- ".gif" => "image/gif",
40
- ".htm" => "text/html",
41
- ".html" => "text/html",
42
- ".jpeg" => "image/jpeg",
43
- ".jpg" => "image/jpeg",
44
- ".js" => "text/javascript",
45
- ".png" => "image/png",
46
- ".swf" => "application/x-shockwave-flash",
47
- ".txt" => "text/plain"
48
- )
49
-
50
- # Making sure file uploads above 64k always work when using IE or Safari
51
- # For more information, see http://trac.lighttpd.net/trac/ticket/360
52
- $HTTP["useragent"] =~ "^(.*MSIE.*)|(.*AppleWebKit.*)$" {
53
- server.max-keep-alive-requests = 0
54
- }
@@ -1,1185 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
5
- <title>Ruby on Rails 2.2 Release Notes</title>
6
- <!--[if lt IE 8]>
7
- <script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js" type="text/javascript"></script>
8
- <![endif]-->
9
- <link href="stylesheets/base.css" media="screen" rel="Stylesheet" type="text/css" />
10
- <link href="stylesheets/forms.css" media="screen" rel="Stylesheet" type="text/css" />
11
- <link href="stylesheets/more.css" media="screen" rel="Stylesheet" type="text/css" />
12
- <style type="text/css">
13
- div#container {
14
- max-width: 900px;
15
- padding-bottom: 3em;
16
- }
17
-
18
- div#content {
19
- margin-left: 200px;
20
- }
21
-
22
- div#container.notoc {
23
- max-width: 600px;
24
- }
25
-
26
- .notoc div#content {
27
- margin-left: 0;
28
- }
29
-
30
- pre {
31
- line-height: 1.4em;
32
- }
33
-
34
- #content p tt {
35
- background: #eeeeee;
36
- border: solid 1px #cccccc;
37
- padding: 3px;
38
- }
39
-
40
- dt {
41
- font-weight: bold;
42
- }
43
- #
44
- #content dt tt {
45
- font-size: 10pt;
46
- }
47
-
48
- dd {
49
- margin-left: 3em;
50
- }
51
-
52
- #content dt tt, #content pre tt {
53
- background: none;
54
- padding: 0;
55
- border: 0;
56
- }
57
-
58
- #content .olist ol {
59
- margin-left: 2em;
60
- }
61
-
62
- #header {
63
- position: relative;
64
- max-width: 840px;
65
- margin-left: auto;
66
- margin-right: auto;
67
- }
68
-
69
- #header.notoc {
70
- max-width: 580px;
71
- }
72
-
73
- #logo {
74
- position: absolute;
75
- left: 10px;
76
- top: 10px;
77
- width: 110px;
78
- height: 140px;
79
- }
80
-
81
- div#header h1#site_title {
82
- background: url('images/ruby_on_rails_by_mike_rundle2.gif') top left no-repeat;
83
- position: absolute;
84
- width: 392px;
85
- height: 55px;
86
- left: 145px;
87
- top: 20px;
88
- margin: 0;
89
- padding: 0;
90
- }
91
-
92
- #site_title span {
93
- display: none;
94
- }
95
-
96
- #site_title_tagline {
97
- display: none;
98
- }
99
-
100
- ul#navMain {
101
- position: absolute;
102
- margin: 0;
103
- padding: 0;
104
- top: 97px;
105
- left: 145px;
106
- }
107
-
108
- .left-floaty, .right-floaty {
109
- padding: 15px;
110
- }
111
-
112
- .admonitionblock,
113
- .tableblock {
114
- margin-left: 1em;
115
- margin-right: 1em;
116
- margin-top: 0.25em;
117
- margin-bottom: 1em;
118
- }
119
-
120
- .admonitionblock .icon {
121
- padding-right: 8px;
122
- }
123
-
124
- .admonitionblock .content {
125
- border: solid 1px #ffda78;
126
- background: #fffebd;
127
- padding: 10px;
128
- padding-top: 8px;
129
- padding-bottom: 8px;
130
- }
131
-
132
- .admonitionblock .title {
133
- font-size: 140%;
134
- margin-bottom: 0.5em;
135
- }
136
-
137
- .tableblock table {
138
- border: solid 1px #aaaaff;
139
- background: #f0f0ff;
140
- }
141
-
142
- .tableblock th {
143
- background: #e0e0e0;
144
- }
145
-
146
- .tableblock th,
147
- .tableblock td {
148
- padding: 3px;
149
- padding-left: 5px;
150
- padding-right: 5px;
151
- }
152
-
153
- .sidebarblock {
154
- margin-top: 0.25em;
155
- margin: 1em;
156
- border: solid 1px #ccccbb;
157
- padding: 8px;
158
- background: #ffffe0;
159
- }
160
-
161
- .sidebarblock .sidebar-title {
162
- font-size: 140%;
163
- font-weight: 600;
164
- margin-bottom: 0.3em;
165
- }
166
-
167
- .sidebarblock .sidebar-content > .para:last-child > p {
168
- margin-bottom: 0;
169
- }
170
-
171
- .sidebarblock .sidebar-title a {
172
- text-decoration: none;
173
- }
174
-
175
- .sidebarblock .sidebar-title a:hover {
176
- text-decoration: underline;
177
- }
178
-
179
- </style>
180
- </head>
181
- <body>
182
- <div id="header" >
183
- <div id="logo">
184
- <a href="index.html" title="Ruby on Rails"><img src="images/rails_logo_remix.gif" alt="Rails" height="140" width="110" /></a>
185
- </div>
186
-
187
- <h1 id="site_title"><span>Ruby on Rails</span></h1>
188
- <h2 id="site_title_tagline">Sustainable productivity for web-application development</h2>
189
-
190
- <ul id="navMain">
191
- <li class="first-child"><a href="http://www.rubyonrails.org/" title="Ruby on Rails" class="ruby_on_rails">Ruby on Rails</a></li>
192
- <li><a class="manuals" href="index.html" title="Manuals Index">Guides Index</a></li>
193
- </ul>
194
- </div>
195
-
196
- <div id="container">
197
-
198
- <div id="sidebar">
199
- <h2>Chapters</h2>
200
- <ol>
201
- <li>
202
- <a href="#_infrastructure">Infrastructure</a>
203
- <ul>
204
-
205
- <li><a href="#_internationalization">Internationalization</a></li>
206
-
207
- <li><a href="#_compatibility_with_ruby_1_9_and_jruby">Compatibility with Ruby 1.9 and JRuby</a></li>
208
-
209
- </ul>
210
- </li>
211
- <li>
212
- <a href="#_documentation">Documentation</a>
213
- </li>
214
- <li>
215
- <a href="#_better_integration_with_http_out_of_the_box_etag_support">Better integration with HTTP : Out of the box ETag support</a>
216
- </li>
217
- <li>
218
- <a href="#_thread_safety">Thread Safety</a>
219
- </li>
220
- <li>
221
- <a href="#_active_record">Active Record</a>
222
- <ul>
223
-
224
- <li><a href="#_transactional_migrations">Transactional Migrations</a></li>
225
-
226
- <li><a href="#_connection_pooling">Connection Pooling</a></li>
227
-
228
- <li><a href="#_hashes_for_join_table_conditions">Hashes for Join Table Conditions</a></li>
229
-
230
- <li><a href="#_new_dynamic_finders">New Dynamic Finders</a></li>
231
-
232
- <li><a href="#_associations_respect_private_protected_scope">Associations Respect Private/Protected Scope</a></li>
233
-
234
- <li><a href="#_other_activerecord_changes">Other ActiveRecord Changes</a></li>
235
-
236
- </ul>
237
- </li>
238
- <li>
239
- <a href="#_action_controller">Action Controller</a>
240
- <ul>
241
-
242
- <li><a href="#_shallow_route_nesting">Shallow Route Nesting</a></li>
243
-
244
- <li><a href="#_method_arrays_for_member_or_collection_routes">Method Arrays for Member or Collection Routes</a></li>
245
-
246
- <li><a href="#_resources_with_specific_actions">Resources With Specific Actions</a></li>
247
-
248
- <li><a href="#_other_action_controller_changes">Other Action Controller Changes</a></li>
249
-
250
- </ul>
251
- </li>
252
- <li>
253
- <a href="#_action_view">Action View</a>
254
- </li>
255
- <li>
256
- <a href="#_action_mailer">Action Mailer</a>
257
- </li>
258
- <li>
259
- <a href="#_active_support">Active Support</a>
260
- <ul>
261
-
262
- <li><a href="#_memoization">Memoization</a></li>
263
-
264
- <li><a href="#_tt_each_with_object_tt"><tt>each_with_object</tt></a></li>
265
-
266
- <li><a href="#_delegates_with_prefixes">Delegates With Prefixes</a></li>
267
-
268
- <li><a href="#_other_active_support_changes">Other Active Support Changes</a></li>
269
-
270
- </ul>
271
- </li>
272
- <li>
273
- <a href="#_railties">Railties</a>
274
- <ul>
275
-
276
- <li><a href="#_tt_config_gems_tt"><tt>config.gems</tt></a></li>
277
-
278
- <li><a href="#_other_railties_changes">Other Railties Changes</a></li>
279
-
280
- </ul>
281
- </li>
282
- <li>
283
- <a href="#_deprecated">Deprecated</a>
284
- </li>
285
- <li>
286
- <a href="#_credits">Credits</a>
287
- </li>
288
- </ol>
289
- </div>
290
-
291
- <div id="content">
292
- <h1>Ruby on Rails 2.2 Release Notes</h1>
293
- <div id="preamble">
294
- <div class="sectionbody">
295
- <div class="para"><p>Rails 2.2 delivers a number of new and improved features. This list covers the major upgrades, but doesn't include every little bug fix and change. If you want to see everything, check out the <a href="http://github.com/rails/rails/commits/master">list of commits</a> in the main Rails repository on GitHub.</p></div>
296
- <div class="para"><p>Along with Rails, 2.2 marks the launch of the <a href="http://guides.rubyonrails.org/">Ruby on Rails Guides</a>, the first results of the ongoing <a href="http://hackfest.rubyonrails.org/guide">Rails Guides hackfest</a>. This site will deliver high-quality documentation of the major features of Rails.</p></div>
297
- </div>
298
- </div>
299
- <h2 id="_infrastructure">1. Infrastructure</h2>
300
- <div class="sectionbody">
301
- <div class="para"><p>Rails 2.2 is a significant release for the infrastructure that keeps Rails humming along and connected to the rest of the world.</p></div>
302
- <h3 id="_internationalization">1.1. Internationalization</h3>
303
- <div class="para"><p>Rails 2.2 supplies an easy system for internationalization (or i18n, for those of you tired of typing).</p></div>
304
- <div class="ilist"><ul>
305
- <li>
306
- <p>
307
- Lead Contributors: Rails i18 Team
308
- </p>
309
- </li>
310
- <li>
311
- <p>
312
- More information :
313
- </p>
314
- <div class="ilist"><ul>
315
- <li>
316
- <p>
317
- <a href="http://rails-i18n.org">Official Rails i18 website</a>
318
- </p>
319
- </li>
320
- <li>
321
- <p>
322
- <a href="http://www.artweb-design.de/2008/7/18/finally-ruby-on-rails-gets-internationalized">Finally. Ruby on Rails gets internationalized</a>
323
- </p>
324
- </li>
325
- <li>
326
- <p>
327
- <a href="http://i18n-demo.phusion.nl">Localizing Rails : Demo application</a>
328
- </p>
329
- </li>
330
- </ul></div>
331
- </li>
332
- </ul></div>
333
- <h3 id="_compatibility_with_ruby_1_9_and_jruby">1.2. Compatibility with Ruby 1.9 and JRuby</h3>
334
- <div class="para"><p>Along with thread safety, a lot of work has been done to make Rails work well with JRuby and the upcoming Ruby 1.9. With Ruby 1.9 being a moving target, running edge Rails on edge Ruby is still a hit-or-miss proposition, but Rails is ready to make the transition to Ruby 1.9 when the latter is released.</p></div>
335
- </div>
336
- <h2 id="_documentation">2. Documentation</h2>
337
- <div class="sectionbody">
338
- <div class="para"><p>The internal documentation of Rails, in the form of code comments, has been improved in numerous places. In addition, the <a href="http://guides.rubyonrails.org/">Ruby on Rails Guides</a> project is the definitive source for information on major Rails components. In its first official release, the Guides page includes:</p></div>
339
- <div class="ilist"><ul>
340
- <li>
341
- <p>
342
- <a href="http://guides.rubyonrails.org/getting_started_with_rails.html">Getting Started with Rails</a>
343
- </p>
344
- </li>
345
- <li>
346
- <p>
347
- <a href="http://guides.rubyonrails.org/migrations.html">Rails Database Migrations</a>
348
- </p>
349
- </li>
350
- <li>
351
- <p>
352
- <a href="http://guides.rubyonrails.org/association_basics.html">Active Record Associations</a>
353
- </p>
354
- </li>
355
- <li>
356
- <p>
357
- <a href="http://guides.rubyonrails.org/finders.html">Active Record Finders</a>
358
- </p>
359
- </li>
360
- <li>
361
- <p>
362
- <a href="http://guides.rubyonrails.org/layouts_and_rendering.html">Layouts and Rendering in Rails</a>
363
- </p>
364
- </li>
365
- <li>
366
- <p>
367
- <a href="http://guides.rubyonrails.org/form_helpers.html">Action View Form Helpers</a>
368
- </p>
369
- </li>
370
- <li>
371
- <p>
372
- <a href="http://guides.rubyonrails.org/routing_outside_in.html">Rails Routing from the Outside In</a>
373
- </p>
374
- </li>
375
- <li>
376
- <p>
377
- <a href="http://guides.rubyonrails.org/actioncontroller_basics.html">Basics of Action Controller</a>
378
- </p>
379
- </li>
380
- <li>
381
- <p>
382
- <a href="http://guides.rubyonrails.org/caching_with_rails.html">Rails Caching</a>
383
- </p>
384
- </li>
385
- <li>
386
- <p>
387
- <a href="http://guides.rubyonrails.org/testing_rails_applications.html">Testing Rails Applications</a>
388
- </p>
389
- </li>
390
- <li>
391
- <p>
392
- <a href="http://guides.rubyonrails.org/security.html">Securing Rails Applications</a>
393
- </p>
394
- </li>
395
- <li>
396
- <p>
397
- <a href="http://guides.rubyonrails.org/debugging_rails_applications.html">Debugging Rails Applications</a>
398
- </p>
399
- </li>
400
- <li>
401
- <p>
402
- <a href="http://guides.rubyonrails.org/benchmarking_and_profiling.html">Benchmarking and Profiling Rails Applications</a>
403
- </p>
404
- </li>
405
- <li>
406
- <p>
407
- <a href="http://guides.rubyonrails.org/creating_plugins.html">The Basics of Creating Rails Plugins</a>
408
- </p>
409
- </li>
410
- </ul></div>
411
- <div class="para"><p>All told, the Guides provide tens of thousands of words of guidance for beginning and intermediate Rails developers.</p></div>
412
- <div class="para"><p>If you want to generate these guides locally, inside your application:</p></div>
413
- <div class="listingblock">
414
- <div class="content"><!-- Generator: GNU source-highlight 2.9
415
- by Lorenzo Bettini
416
- http://www.lorenzobettini.it
417
- http://www.gnu.org/software/src-highlite -->
418
- <pre><tt>rake doc<span style="color: #990000">:</span>guides
419
- </tt></pre></div></div>
420
- <div class="para"><p>This will put the guides inside <tt>RAILS_ROOT/doc/guides</tt> and you may start surfing straight away by opening <tt>RAILS_ROOT/doc/guides/index.html</tt> in your favourite browser.</p></div>
421
- <div class="ilist"><ul>
422
- <li>
423
- <p>
424
- Lead Contributors: <a href="http://guides.rails.info/authors.html">Rails Documentation Team</a>
425
- </p>
426
- </li>
427
- <li>
428
- <p>
429
- Major contributions from <a href="http://advogato.org/person/fxn/diary.html">Xavier Noria</a> and <a href="http://izumi.plan99.net/blog/">Hongli Lai</a>.
430
- </p>
431
- </li>
432
- <li>
433
- <p>
434
- More information:
435
- </p>
436
- <div class="ilist"><ul>
437
- <li>
438
- <p>
439
- <a href="http://hackfest.rubyonrails.org/guide">Rails Guides hackfest</a>
440
- </p>
441
- </li>
442
- <li>
443
- <p>
444
- <a href="http://weblog.rubyonrails.org/2008/5/2/help-improve-rails-documentation-on-git-branch">Help improve Rails documentation on Git branch</a>
445
- </p>
446
- </li>
447
- </ul></div>
448
- </li>
449
- </ul></div>
450
- </div>
451
- <h2 id="_better_integration_with_http_out_of_the_box_etag_support">3. Better integration with HTTP : Out of the box ETag support</h2>
452
- <div class="sectionbody">
453
- <div class="para"><p>Supporting the etag and last modified timestamp in HTTP headers means that Rails can now send back an empty response if it gets a request for a resource that hasn't been modified lately. This allows you to check whether a response needs to be sent at all.</p></div>
454
- <div class="listingblock">
455
- <div class="content"><!-- Generator: GNU source-highlight 2.9
456
- by Lorenzo Bettini
457
- http://www.lorenzobettini.it
458
- http://www.gnu.org/software/src-highlite -->
459
- <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> ArticlesController <span style="color: #990000">&lt;</span> ApplicationController
460
- <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> show_with_respond_to_block
461
- <span style="color: #009900">@article</span> <span style="color: #990000">=</span> Article<span style="color: #990000">.</span>find<span style="color: #990000">(</span>params<span style="color: #990000">[:</span>id<span style="color: #990000">])</span>
462
-
463
- <span style="font-style: italic"><span style="color: #9A1900"># If the request sends headers that differs from the options provided to stale?, then</span></span>
464
- <span style="font-style: italic"><span style="color: #9A1900"># the request is indeed stale and the respond_to block is triggered (and the options</span></span>
465
- <span style="font-style: italic"><span style="color: #9A1900"># to the stale? call is set on the response).</span></span>
466
- <span style="font-style: italic"><span style="color: #9A1900">#</span></span>
467
- <span style="font-style: italic"><span style="color: #9A1900"># If the request headers match, then the request is fresh and the respond_to block is</span></span>
468
- <span style="font-style: italic"><span style="color: #9A1900"># not triggered. Instead the default render will occur, which will check the last-modified</span></span>
469
- <span style="font-style: italic"><span style="color: #9A1900"># and etag headers and conclude that it only needs to send a "304 Not Modified" instead</span></span>
470
- <span style="font-style: italic"><span style="color: #9A1900"># of rendering the template.</span></span>
471
- <span style="font-weight: bold"><span style="color: #0000FF">if</span></span> stale?<span style="color: #990000">(:</span>last_modified <span style="color: #990000">=&gt;</span> <span style="color: #009900">@article</span><span style="color: #990000">.</span>published_at<span style="color: #990000">.</span>utc<span style="color: #990000">,</span> <span style="color: #990000">:</span>etag <span style="color: #990000">=&gt;</span> <span style="color: #009900">@article</span><span style="color: #990000">)</span>
472
- respond_to <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>wants<span style="color: #990000">|</span>
473
- <span style="font-style: italic"><span style="color: #9A1900"># normal response processing</span></span>
474
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
475
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
476
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
477
-
478
- <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> show_with_implied_render
479
- <span style="color: #009900">@article</span> <span style="color: #990000">=</span> Article<span style="color: #990000">.</span>find<span style="color: #990000">(</span>params<span style="color: #990000">[:</span>id<span style="color: #990000">])</span>
480
-
481
- <span style="font-style: italic"><span style="color: #9A1900"># Sets the response headers and checks them against the request, if the request is stale</span></span>
482
- <span style="font-style: italic"><span style="color: #9A1900"># (i.e. no match of either etag or last-modified), then the default render of the template happens.</span></span>
483
- <span style="font-style: italic"><span style="color: #9A1900"># If the request is fresh, then the default render will return a "304 Not Modified"</span></span>
484
- <span style="font-style: italic"><span style="color: #9A1900"># instead of rendering the template.</span></span>
485
- fresh_when<span style="color: #990000">(:</span>last_modified <span style="color: #990000">=&gt;</span> <span style="color: #009900">@article</span><span style="color: #990000">.</span>published_at<span style="color: #990000">.</span>utc<span style="color: #990000">,</span> <span style="color: #990000">:</span>etag <span style="color: #990000">=&gt;</span> <span style="color: #009900">@article</span><span style="color: #990000">)</span>
486
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
487
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
488
- </tt></pre></div></div>
489
- </div>
490
- <h2 id="_thread_safety">4. Thread Safety</h2>
491
- <div class="sectionbody">
492
- <div class="para"><p>The work done to make Rails thread-safe is rolling out in Rails 2.2. Depending on your web server infrastructure, this means you can handle more requests with fewer copies of Rails in memory, leading to better server performance and higher utilization of multiple cores.</p></div>
493
- <div class="para"><p>To enable multithreaded dispatching in production mode of your application, add the following line in your <tt>config/environments/production.rb</tt>:</p></div>
494
- <div class="listingblock">
495
- <div class="content"><!-- Generator: GNU source-highlight 2.9
496
- by Lorenzo Bettini
497
- http://www.lorenzobettini.it
498
- http://www.gnu.org/software/src-highlite -->
499
- <pre><tt>config<span style="color: #990000">.</span>threadsafe!
500
- </tt></pre></div></div>
501
- <div class="ilist"><ul>
502
- <li>
503
- <p>
504
- More information :
505
- </p>
506
- <div class="ilist"><ul>
507
- <li>
508
- <p>
509
- <a href="http://m.onkey.org/2008/10/23/thread-safety-for-your-rails">Thread safety for your Rails</a>
510
- </p>
511
- </li>
512
- <li>
513
- <p>
514
- <a href="http://weblog.rubyonrails.org/2008/8/16/josh-peek-officially-joins-the-rails-core">Thread safety project announcement</a>
515
- </p>
516
- </li>
517
- <li>
518
- <p>
519
- <a href="http://blog.headius.com/2008/08/qa-what-thread-safe-rails-means.html">Q/A: What Thread-safe Rails Means</a>
520
- </p>
521
- </li>
522
- </ul></div>
523
- </li>
524
- </ul></div>
525
- </div>
526
- <h2 id="_active_record">5. Active Record</h2>
527
- <div class="sectionbody">
528
- <div class="para"><p>There are two big additions to talk about here: transactional migrations and pooled database transactions. There's also a new (and cleaner) syntax for join table conditions, as well as a number of smaller improvements.</p></div>
529
- <h3 id="_transactional_migrations">5.1. Transactional Migrations</h3>
530
- <div class="para"><p>Historically, multiple-step Rails migrations have been a source of trouble. If something went wrong during a migration, everything before the error changed the database and everything after the error wasn't applied. Also, the migration version was stored as having been executed, which means that it couldn't be simply rerun by <tt>rake db:migrate:redo</tt> after you fix the problem. Transactional migrations change this by wrapping migration steps in a DDL transaction, so that if any of them fail, the entire migration is undone. In Rails 2.2, transactional migrations are supported on PostgreSQL out of the box. The code is extensible to other database types in the future - and IBM has already extended it to support the DB2 adapter.</p></div>
531
- <div class="ilist"><ul>
532
- <li>
533
- <p>
534
- Lead Contributor: <a href="http://adam.blog.heroku.com/">Adam Wiggins</a>
535
- </p>
536
- </li>
537
- <li>
538
- <p>
539
- More information:
540
- </p>
541
- <div class="ilist"><ul>
542
- <li>
543
- <p>
544
- <a href="http://adam.blog.heroku.com/past/2008/9/3/ddl_transactions/">DDL Transactions</a>
545
- </p>
546
- </li>
547
- <li>
548
- <p>
549
- <a href="http://db2onrails.com/2008/11/08/a-major-milestone-for-db2-on-rails/">A major milestone for DB2 on Rails</a>
550
- </p>
551
- </li>
552
- </ul></div>
553
- </li>
554
- </ul></div>
555
- <h3 id="_connection_pooling">5.2. Connection Pooling</h3>
556
- <div class="para"><p>Connection pooling lets Rails distribute database requests across a pool of database connections that will grow to a maximum size (by default 5, but you can add a <tt>pool</tt> key to your <tt>database.yml</tt> to adjust this). This helps remove bottlenecks in applications that support many concurrent users. There's also a <tt>wait_timeout</tt> that defaults to 5 seconds before giving up. <tt>ActiveRecord::Base.connection_pool</tt> gives you direct access to the pool if you need it.</p></div>
557
- <div class="listingblock">
558
- <div class="content"><!-- Generator: GNU source-highlight 2.9
559
- by Lorenzo Bettini
560
- http://www.lorenzobettini.it
561
- http://www.gnu.org/software/src-highlite -->
562
- <pre><tt>development<span style="color: #990000">:</span>
563
- adapter<span style="color: #990000">:</span> mysql
564
- username<span style="color: #990000">:</span> root
565
- database<span style="color: #990000">:</span> sample_development
566
- pool<span style="color: #990000">:</span> <span style="color: #993399">10</span>
567
- wait_timeout<span style="color: #990000">:</span> <span style="color: #993399">10</span>
568
- </tt></pre></div></div>
569
- <div class="ilist"><ul>
570
- <li>
571
- <p>
572
- Lead Contributor: <a href="http://blog.nicksieger.com/">Nick Sieger</a>
573
- </p>
574
- </li>
575
- <li>
576
- <p>
577
- More information:
578
- </p>
579
- <div class="ilist"><ul>
580
- <li>
581
- <p>
582
- <a href="http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-connection-pools">What's New in Edge Rails: Connection Pools</a>
583
- </p>
584
- </li>
585
- </ul></div>
586
- </li>
587
- </ul></div>
588
- <h3 id="_hashes_for_join_table_conditions">5.3. Hashes for Join Table Conditions</h3>
589
- <div class="para"><p>You can now specify conditions on join tables using a hash. This is a big help if you need to query across complex joins.</p></div>
590
- <div class="listingblock">
591
- <div class="content"><!-- Generator: GNU source-highlight 2.9
592
- by Lorenzo Bettini
593
- http://www.lorenzobettini.it
594
- http://www.gnu.org/software/src-highlite -->
595
- <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> Photo <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
596
- belongs_to <span style="color: #990000">:</span>product
597
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
598
-
599
- <span style="font-weight: bold"><span style="color: #0000FF">class</span></span> Product <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
600
- has_many <span style="color: #990000">:</span>photos
601
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
602
-
603
- <span style="font-style: italic"><span style="color: #9A1900"># Get all products with copyright-free photos:</span></span>
604
- Product<span style="color: #990000">.</span>all<span style="color: #990000">(:</span>joins <span style="color: #990000">=&gt;</span> <span style="color: #990000">:</span>photos<span style="color: #990000">,</span> <span style="color: #990000">:</span>conditions <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">{</span> <span style="color: #990000">:</span>photos <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">{</span> <span style="color: #990000">:</span>copyright <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">false</span></span> <span style="color: #FF0000">}}</span><span style="color: #990000">)</span>
605
- </tt></pre></div></div>
606
- <div class="ilist"><ul>
607
- <li>
608
- <p>
609
- More information:
610
- </p>
611
- <div class="ilist"><ul>
612
- <li>
613
- <p>
614
- <a href="http://ryandaigle.com/articles/2008/7/7/what-s-new-in-edge-rails-easy-join-table-conditions">What's New in Edge Rails: Easy Join Table Conditions</a>
615
- </p>
616
- </li>
617
- </ul></div>
618
- </li>
619
- </ul></div>
620
- <h3 id="_new_dynamic_finders">5.4. New Dynamic Finders</h3>
621
- <div class="para"><p>Two new sets of methods have been added to Active Record's dynamic finders family.</p></div>
622
- <h4 id="_tt_find_last_by_lt_attribute_gt_tt">5.4.1. <tt>find_last_by_&lt;attribute&gt;</tt></h4>
623
- <div class="para"><p>The <tt>find_last_by_&lt;attribute&gt;</tt> method is equivalent to <tt>Model.last(:conditions &#8658; {:attribute &#8658; value})</tt></p></div>
624
- <div class="listingblock">
625
- <div class="content"><!-- Generator: GNU source-highlight 2.9
626
- by Lorenzo Bettini
627
- http://www.lorenzobettini.it
628
- http://www.gnu.org/software/src-highlite -->
629
- <pre><tt><span style="font-style: italic"><span style="color: #9A1900"># Get the last user who signed up from London</span></span>
630
- User<span style="color: #990000">.</span>find_last_by_city<span style="color: #990000">(</span><span style="color: #FF0000">'London'</span><span style="color: #990000">)</span>
631
- </tt></pre></div></div>
632
- <div class="ilist"><ul>
633
- <li>
634
- <p>
635
- Lead Contributor: <a href="http://www.workingwithrails.com/person/9147-emilio-tagua">Emilio Tagua</a>
636
- </p>
637
- </li>
638
- </ul></div>
639
- <h4 id="_tt_find_by_lt_attribute_gt_tt">5.4.2. <tt>find_by_&lt;attribute&gt;!</tt></h4>
640
- <div class="para"><p>The new bang! version of <tt>find_by_&lt;attribute&gt;!</tt> is equivalent to <tt>Model.first(:conditions &#8658; {:attribute &#8658; value}) || raise ActiveRecord::RecordNotFound</tt> Instead of returning <tt>nil</tt> if it can't find a matching record, this method will raise an exception if it cannot find a match.</p></div>
641
- <div class="listingblock">
642
- <div class="content"><!-- Generator: GNU source-highlight 2.9
643
- by Lorenzo Bettini
644
- http://www.lorenzobettini.it
645
- http://www.gnu.org/software/src-highlite -->
646
- <pre><tt><span style="font-style: italic"><span style="color: #9A1900"># Raise ActiveRecord::RecordNotFound exception if 'Moby' hasn't signed up yet!</span></span>
647
- User<span style="color: #990000">.</span>find_by_name!<span style="color: #990000">(</span><span style="color: #FF0000">'Moby'</span><span style="color: #990000">)</span>
648
- </tt></pre></div></div>
649
- <div class="ilist"><ul>
650
- <li>
651
- <p>
652
- Lead Contributor: <a href="http://blog.hasmanythrough.com">Josh Susser</a>
653
- </p>
654
- </li>
655
- </ul></div>
656
- <h3 id="_associations_respect_private_protected_scope">5.5. Associations Respect Private/Protected Scope</h3>
657
- <div class="para"><p>Active Record association proxies now respect the scope of methods on the proxied object. Previously (given User has_one :account) <tt>@user.account.private_method</tt> would call the private method on the associated Account object. That fails in Rails 2.2; if you need this functionality, you should use <tt>@user.account.send(:private_method)</tt> (or make the method public instead of private or protected). Please note that if you're overriding <tt>method_missing</tt>, you should also override <tt>respond_to</tt> to match the behavior in order for associations to function normally.</p></div>
658
- <div class="ilist"><ul>
659
- <li>
660
- <p>
661
- Lead Contributor: Adam Milligan
662
- </p>
663
- </li>
664
- <li>
665
- <p>
666
- More information:
667
- </p>
668
- <div class="ilist"><ul>
669
- <li>
670
- <p>
671
- <a href="http://afreshcup.com/2008/10/24/rails-22-change-private-methods-on-association-proxies-are-private/">Rails 2.2 Change: Private Methods on Association Proxies are Private</a>
672
- </p>
673
- </li>
674
- </ul></div>
675
- </li>
676
- </ul></div>
677
- <h3 id="_other_activerecord_changes">5.6. Other ActiveRecord Changes</h3>
678
- <div class="ilist"><ul>
679
- <li>
680
- <p>
681
- <tt>rake db:migrate:redo</tt> now accepts an optional VERSION to target that specific migration to redo
682
- </p>
683
- </li>
684
- <li>
685
- <p>
686
- Set <tt>config.active_record.timestamped_migrations = false</tt> to have migrations with numeric prefix instead of UTC timestamp.
687
- </p>
688
- </li>
689
- <li>
690
- <p>
691
- Counter cache columns (for associations declared with <tt>:counter_cache &#8658; true</tt>) do not need to be initialized to zero any longer.
692
- </p>
693
- </li>
694
- <li>
695
- <p>
696
- <tt>ActiveRecord::Base.human_name</tt> for an internationalization-aware humane translation of model names
697
- </p>
698
- </li>
699
- </ul></div>
700
- </div>
701
- <h2 id="_action_controller">6. Action Controller</h2>
702
- <div class="sectionbody">
703
- <div class="para"><p>On the controller side, there are several changes that will help tidy up your routes. There are also some internal changes in the routing engine to lower memory usage on complex applications.</p></div>
704
- <h3 id="_shallow_route_nesting">6.1. Shallow Route Nesting</h3>
705
- <div class="para"><p>Shallow route nesting provides a solution to the well-known difficulty of using deeply-nested resources. With shallow nesting, you need only supply enough information to uniquely identify the resource that you want to work with.</p></div>
706
- <div class="listingblock">
707
- <div class="content"><!-- Generator: GNU source-highlight 2.9
708
- by Lorenzo Bettini
709
- http://www.lorenzobettini.it
710
- http://www.gnu.org/software/src-highlite -->
711
- <pre><tt>map<span style="color: #990000">.</span>resources <span style="color: #990000">:</span>publishers<span style="color: #990000">,</span> <span style="color: #990000">:</span>shallow <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span> <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>publisher<span style="color: #990000">|</span>
712
- publisher<span style="color: #990000">.</span>resources <span style="color: #990000">:</span>magazines <span style="font-weight: bold"><span style="color: #0000FF">do</span></span> <span style="color: #990000">|</span>magazine<span style="color: #990000">|</span>
713
- magazine<span style="color: #990000">.</span>resources <span style="color: #990000">:</span>photos
714
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
715
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
716
- </tt></pre></div></div>
717
- <div class="para"><p>This will enable recognition of (among others) these routes:</p></div>
718
- <div class="listingblock">
719
- <div class="content">
720
- <pre><tt>/publishers/1 ==&gt; publisher_path(1)
721
- /publishers/1/magazines ==&gt; publisher_magazines_path(1)
722
- /magazines/2 ==&gt; magazine_path(2)
723
- /magazines/2/photos ==&gt; magazines_photos_path(2)
724
- /photos/3 ==&gt; photo_path(3)</tt></pre>
725
- </div></div>
726
- <div class="ilist"><ul>
727
- <li>
728
- <p>
729
- Lead Contributor: <a href="http://www.unwwwired.net/">S. Brent Faulkner</a>
730
- </p>
731
- </li>
732
- <li>
733
- <p>
734
- More information:
735
- </p>
736
- <div class="ilist"><ul>
737
- <li>
738
- <p>
739
- <a href="http://guides.rails.info/routing/routing_outside_in.html#_nested_resources">Rails Routing from the Outside In</a>
740
- </p>
741
- </li>
742
- <li>
743
- <p>
744
- <a href="http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-shallow-routes">What's New in Edge Rails: Shallow Routes</a>
745
- </p>
746
- </li>
747
- </ul></div>
748
- </li>
749
- </ul></div>
750
- <h3 id="_method_arrays_for_member_or_collection_routes">6.2. Method Arrays for Member or Collection Routes</h3>
751
- <div class="para"><p>You can now supply an array of methods for new member or collection routes. This removes the annoyance of having to define a route as accepting any verb as soon as you need it to handle more than one. With Rails 2.2, this is a legitimate route declaration:</p></div>
752
- <div class="listingblock">
753
- <div class="content"><!-- Generator: GNU source-highlight 2.9
754
- by Lorenzo Bettini
755
- http://www.lorenzobettini.it
756
- http://www.gnu.org/software/src-highlite -->
757
- <pre><tt>map<span style="color: #990000">.</span>resources <span style="color: #990000">:</span>photos<span style="color: #990000">,</span> <span style="color: #990000">:</span>collection <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">{</span> <span style="color: #990000">:</span>search <span style="color: #990000">=&gt;</span> <span style="color: #990000">[:</span>get<span style="color: #990000">,</span> <span style="color: #990000">:</span>post<span style="color: #990000">]</span> <span style="color: #FF0000">}</span>
758
- </tt></pre></div></div>
759
- <div class="ilist"><ul>
760
- <li>
761
- <p>
762
- Lead Contributor: <a href="http://brennandunn.com/">Brennan Dunn</a>
763
- </p>
764
- </li>
765
- </ul></div>
766
- <h3 id="_resources_with_specific_actions">6.3. Resources With Specific Actions</h3>
767
- <div class="para"><p>By default, when you use <tt>map.resources</tt> to create a route, Rails generates routes for seven default actions (index, show, create, new, edit, update, and destroy). But each of these routes takes up memory in your application, and causes Rails to generate additional routing logic. Now you can use the <tt>:only</tt> and <tt>:except</tt> options to fine-tune the routes that Rails will generate for resources. You can supply a single action, an array of actions, or the special <tt>:all</tt> or <tt>:none</tt> options. These options are inherited by nested resources.</p></div>
768
- <div class="listingblock">
769
- <div class="content"><!-- Generator: GNU source-highlight 2.9
770
- by Lorenzo Bettini
771
- http://www.lorenzobettini.it
772
- http://www.gnu.org/software/src-highlite -->
773
- <pre><tt>map<span style="color: #990000">.</span>resources <span style="color: #990000">:</span>photos<span style="color: #990000">,</span> <span style="color: #990000">:</span>only <span style="color: #990000">=&gt;</span> <span style="color: #990000">[:</span>index<span style="color: #990000">,</span> <span style="color: #990000">:</span>show<span style="color: #990000">]</span>
774
- map<span style="color: #990000">.</span>resources <span style="color: #990000">:</span>products<span style="color: #990000">,</span> <span style="color: #990000">:</span>except <span style="color: #990000">=&gt;</span> <span style="color: #990000">:</span>destroy
775
- </tt></pre></div></div>
776
- <div class="ilist"><ul>
777
- <li>
778
- <p>
779
- Lead Contributor: <a href="http://experthuman.com/">Tom Stuart</a>
780
- </p>
781
- </li>
782
- </ul></div>
783
- <h3 id="_other_action_controller_changes">6.4. Other Action Controller Changes</h3>
784
- <div class="ilist"><ul>
785
- <li>
786
- <p>
787
- You can now easily <a href="http://m.onkey.org/2008/7/20/rescue-from-dispatching">show a custom error page</a> for exceptions raised while routing a request.
788
- </p>
789
- </li>
790
- <li>
791
- <p>
792
- The HTTP Accept header is disabled by default now. You should prefer the use of formatted URLs (such as <tt>/customers/1.xml</tt>) to indicate the format that you want. If you need the Accept headers, you can turn them back on with <tt>config.action_controller.user_accept_header = true</tt>.
793
- </p>
794
- </li>
795
- <li>
796
- <p>
797
- Benchmarking numbers are now reported in milliseconds rather than tiny fractions of seconds
798
- </p>
799
- </li>
800
- <li>
801
- <p>
802
- Rails now supports HTTP-only cookies (and uses them for sessions), which help mitigate some cross-site scripting risks in newer browsers.
803
- </p>
804
- </li>
805
- <li>
806
- <p>
807
- <tt>redirect_to</tt> now fully supports URI schemes (so, for example, you can redirect to a svn+ssh: URI).
808
- </p>
809
- </li>
810
- <li>
811
- <p>
812
- <tt>render</tt> now supports a <tt>:js</tt> option to render plain vanilla javascript with the right mime type.
813
- </p>
814
- </li>
815
- <li>
816
- <p>
817
- Request forgery protection has been tightened up to apply to HTML-formatted content requests only.
818
- </p>
819
- </li>
820
- <li>
821
- <p>
822
- Polymorphic URLs behave more sensibly if a passed parameter is nil. For example, calling <tt>polymorphic_path([@project, @date, @area])</tt> with a nil date will give you <tt>project_area_path</tt>.
823
- </p>
824
- </li>
825
- </ul></div>
826
- </div>
827
- <h2 id="_action_view">7. Action View</h2>
828
- <div class="sectionbody">
829
- <div class="ilist"><ul>
830
- <li>
831
- <p>
832
- <tt>javascript_include_tag</tt> and <tt>stylesheet_link_tag</tt> support a new <tt>:recursive</tt> option to be used along with <tt>:all</tt>, so that you can load an entire tree of files with a single line of code.
833
- </p>
834
- </li>
835
- <li>
836
- <p>
837
- The included Prototype javascript library has been upgraded to version 1.6.0.3.
838
- </p>
839
- </li>
840
- <li>
841
- <p>
842
- <tt>RJS#page.reload</tt> to reload the browser's current location via javascript
843
- </p>
844
- </li>
845
- <li>
846
- <p>
847
- The <tt>atom_feed</tt> helper now takes an <tt>:instruct</tt> option to let you insert XML processing instructions.
848
- </p>
849
- </li>
850
- </ul></div>
851
- </div>
852
- <h2 id="_action_mailer">8. Action Mailer</h2>
853
- <div class="sectionbody">
854
- <div class="para"><p>Action Mailer now supports mailer layouts. You can make your HTML emails as pretty as your in-browser views by supplying an appropriately-named layout - for example, the <tt>CustomerMailer</tt> class expects to use <tt>layouts/customer_mailer.html.erb</tt>.</p></div>
855
- <div class="ilist"><ul>
856
- <li>
857
- <p>
858
- More information:
859
- </p>
860
- <div class="ilist"><ul>
861
- <li>
862
- <p>
863
- <a href="http://ryandaigle.com/articles/2008/9/7/what-s-new-in-edge-rails-mailer-layouts">What's New in Edge Rails: Mailer Layouts</a>
864
- </p>
865
- </li>
866
- </ul></div>
867
- </li>
868
- </ul></div>
869
- <div class="para"><p>Action Mailer now offers built-in support for GMail's SMTP servers, by turning on STARTTLS automatically. This requires Ruby 1.8.7 to be installed.</p></div>
870
- </div>
871
- <h2 id="_active_support">9. Active Support</h2>
872
- <div class="sectionbody">
873
- <div class="para"><p>Active Support now offers built-in memoization for Rails applications, the <tt>each_with_object</tt> method, prefix support on delegates, and various other new utility methods.</p></div>
874
- <h3 id="_memoization">9.1. Memoization</h3>
875
- <div class="para"><p>Memoization is a pattern of initializing a method once and then stashing its value away for repeat use. You've probably used this pattern in your own applications:</p></div>
876
- <div class="listingblock">
877
- <div class="content"><!-- Generator: GNU source-highlight 2.9
878
- by Lorenzo Bettini
879
- http://www.lorenzobettini.it
880
- http://www.gnu.org/software/src-highlite -->
881
- <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">def</span></span> full_name
882
- <span style="color: #009900">@full_name</span> <span style="color: #990000">||=</span> <span style="color: #FF0000">"#{first_name} #{last_name}"</span>
883
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
884
- </tt></pre></div></div>
885
- <div class="para"><p>Memoization lets you handle this task in a declarative fashion:</p></div>
886
- <div class="listingblock">
887
- <div class="content"><!-- Generator: GNU source-highlight 2.9
888
- by Lorenzo Bettini
889
- http://www.lorenzobettini.it
890
- http://www.gnu.org/software/src-highlite -->
891
- <pre><tt>extend ActiveSupport<span style="color: #990000">::</span>Memoizable
892
-
893
- <span style="font-weight: bold"><span style="color: #0000FF">def</span></span> full_name
894
- <span style="color: #FF0000">"#{first_name} #{last_name}"</span>
895
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
896
- memoize <span style="color: #990000">:</span>full_name
897
- </tt></pre></div></div>
898
- <div class="para"><p>Other features of memoization include <tt>unmemoize</tt>, <tt>unmemoize_all</tt>, and <tt>memoize_all</tt> to turn memoization on or off.</p></div>
899
- <div class="ilist"><ul>
900
- <li>
901
- <p>
902
- Lead Contributor: <a href="http://joshpeek.com/">Josh Peek</a>
903
- </p>
904
- </li>
905
- <li>
906
- <p>
907
- More information:
908
- </p>
909
- <div class="ilist"><ul>
910
- <li>
911
- <p>
912
- <a href="http://ryandaigle.com/articles/2008/7/16/what-s-new-in-edge-rails-memoization">What's New in Edge Rails: Easy Memoization</a>
913
- </p>
914
- </li>
915
- <li>
916
- <p>
917
- <a href="http://www.railway.at/articles/2008/09/20/a-guide-to-memoization">Memo-what? A Guide to Memoization</a>
918
- </p>
919
- </li>
920
- </ul></div>
921
- </li>
922
- </ul></div>
923
- <h3 id="_tt_each_with_object_tt">9.2. <tt>each_with_object</tt></h3>
924
- <div class="para"><p>The <tt>each_with_object</tt> method provides an alternative to <tt>inject</tt>, using a method backported from Ruby 1.9. It iterates over a collection, passing the current element and the memo into the block.</p></div>
925
- <div class="listingblock">
926
- <div class="content"><!-- Generator: GNU source-highlight 2.9
927
- by Lorenzo Bettini
928
- http://www.lorenzobettini.it
929
- http://www.gnu.org/software/src-highlite -->
930
- <pre><tt><span style="color: #990000">%</span>w<span style="color: #990000">(</span>foo bar<span style="color: #990000">).</span>each_with_object<span style="color: #990000">(</span><span style="color: #FF0000">{}</span><span style="color: #990000">)</span> <span style="color: #FF0000">{</span> <span style="color: #990000">|</span>str<span style="color: #990000">,</span> hsh<span style="color: #990000">|</span> hsh<span style="color: #990000">[</span>str<span style="color: #990000">]</span> <span style="color: #990000">=</span> str<span style="color: #990000">.</span>upcase <span style="color: #FF0000">}</span> <span style="font-style: italic"><span style="color: #9A1900">#=&gt; {'foo' =&gt; 'FOO', 'bar' =&gt; 'BAR'}</span></span>
931
- </tt></pre></div></div>
932
- <div class="para"><p>Lead Contributor: <a href="http://therealadam.com/">Adam Keys</a></p></div>
933
- <h3 id="_delegates_with_prefixes">9.3. Delegates With Prefixes</h3>
934
- <div class="para"><p>If you delegate behavior from one class to another, you can now specify a prefix that will be used to identify the delegated methods. For example:</p></div>
935
- <div class="listingblock">
936
- <div class="content"><!-- Generator: GNU source-highlight 2.9
937
- by Lorenzo Bettini
938
- http://www.lorenzobettini.it
939
- http://www.gnu.org/software/src-highlite -->
940
- <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> Vendor <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
941
- has_one <span style="color: #990000">:</span>account
942
- delegate <span style="color: #990000">:</span>email<span style="color: #990000">,</span> <span style="color: #990000">:</span>password<span style="color: #990000">,</span> <span style="color: #990000">:</span>to <span style="color: #990000">=&gt;</span> <span style="color: #990000">:</span>account<span style="color: #990000">,</span> <span style="color: #990000">:</span>prefix <span style="color: #990000">=&gt;</span> <span style="font-weight: bold"><span style="color: #0000FF">true</span></span>
943
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
944
- </tt></pre></div></div>
945
- <div class="para"><p>This will produce delegated methods <tt>vendor#account_email</tt> and <tt>vendor#account_password</tt>. You can also specify a custom prefix:</p></div>
946
- <div class="listingblock">
947
- <div class="content"><!-- Generator: GNU source-highlight 2.9
948
- by Lorenzo Bettini
949
- http://www.lorenzobettini.it
950
- http://www.gnu.org/software/src-highlite -->
951
- <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">class</span></span> Vendor <span style="color: #990000">&lt;</span> ActiveRecord<span style="color: #990000">::</span>Base
952
- has_one <span style="color: #990000">:</span>account
953
- delegate <span style="color: #990000">:</span>email<span style="color: #990000">,</span> <span style="color: #990000">:</span>password<span style="color: #990000">,</span> <span style="color: #990000">:</span>to <span style="color: #990000">=&gt;</span> <span style="color: #990000">:</span>account<span style="color: #990000">,</span> <span style="color: #990000">:</span>prefix <span style="color: #990000">=&gt;</span> <span style="color: #990000">:</span>owner
954
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
955
- </tt></pre></div></div>
956
- <div class="para"><p>This will produce delegated methods <tt>vendor#owner_email</tt> and <tt>vendor#owner_password</tt>.</p></div>
957
- <div class="para"><p>Lead Contributor: <a href="http://workingwithrails.com/person/5830-daniel-schierbeck">Daniel Schierbeck</a></p></div>
958
- <h3 id="_other_active_support_changes">9.4. Other Active Support Changes</h3>
959
- <div class="ilist"><ul>
960
- <li>
961
- <p>
962
- Extensive updates to <tt>ActiveSupport::Multibyte</tt>, including Ruby 1.9 compatibility fixes.
963
- </p>
964
- </li>
965
- <li>
966
- <p>
967
- The addition of <tt>ActiveSupport::Rescuable</tt> allows any class to mix in the <tt>rescue_from</tt> syntax.
968
- </p>
969
- </li>
970
- <li>
971
- <p>
972
- <tt>past?</tt>, <tt>today?</tt> and <tt>future?</tt> for <tt>Date</tt> and <tt>Time</tt> classes to facilitate date/time comparisons.
973
- </p>
974
- </li>
975
- <li>
976
- <p>
977
- <tt>Array#second</tt> through <tt>Array#fifth</tt> as aliases for <tt>Array#[1]</tt> through <tt>Array#[4]</tt>
978
- </p>
979
- </li>
980
- <li>
981
- <p>
982
- <tt>Enumerable#many?</tt> to encapsulate <tt>collection.size &gt; 1</tt>
983
- </p>
984
- </li>
985
- <li>
986
- <p>
987
- <tt>Inflector#parameterize</tt> produces a URL-ready version of its input, for use in <tt>to_param</tt>.
988
- </p>
989
- </li>
990
- <li>
991
- <p>
992
- <tt>Time#advance</tt> recognizes fractional days and weeks, so you can do <tt>1.7.weeks.ago</tt>, <tt>1.5.hours.since</tt>, and so on.
993
- </p>
994
- </li>
995
- <li>
996
- <p>
997
- The included TzInfo library has been upgraded to version 0.3.12.
998
- </p>
999
- </li>
1000
- <li>
1001
- <p>
1002
- <tt>ActiveSuport::StringInquirer</tt> gives you a pretty way to test for equality in strings: <tt>ActiveSupport::StringInquirer.new("abc").abc? &#8658; true</tt>
1003
- </p>
1004
- </li>
1005
- </ul></div>
1006
- </div>
1007
- <h2 id="_railties">10. Railties</h2>
1008
- <div class="sectionbody">
1009
- <div class="para"><p>In Railties (the core code of Rails itself) the biggest changes are in the <tt>config.gems</tt> mechanism.</p></div>
1010
- <h3 id="_tt_config_gems_tt">10.1. <tt>config.gems</tt></h3>
1011
- <div class="para"><p>To avoid deployment issues and make Rails applications more self-contained, it's possible to place copies of all of the gems that your Rails application requires in <tt>/vendor/gems</tt>. This capability first appeared in Rails 2.1, but it's much more flexible and robust in Rails 2.2, handling complicated dependencies between gems. Gem management in Rails includes these commands:</p></div>
1012
- <div class="ilist"><ul>
1013
- <li>
1014
- <p>
1015
- <tt>config.gem <em>gem_name</em></tt> in your <tt>config/environment.rb</tt> file
1016
- </p>
1017
- </li>
1018
- <li>
1019
- <p>
1020
- <tt>rake gems</tt> to list all configured gems, as well as whether they (and their dependencies) are installed or frozen
1021
- </p>
1022
- </li>
1023
- <li>
1024
- <p>
1025
- <tt>rake gems:install</tt> to install missing gems to the computer
1026
- </p>
1027
- </li>
1028
- <li>
1029
- <p>
1030
- <tt>rake gems:unpack</tt> to place a copy of the required gems into <tt>/vendor/gems</tt>
1031
- </p>
1032
- </li>
1033
- <li>
1034
- <p>
1035
- <tt>rake gems:unpack:dependencies</tt> to get copies of the required gems and their dependencies into <tt>/vendor/gems</tt>
1036
- </p>
1037
- </li>
1038
- <li>
1039
- <p>
1040
- <tt>rake gems:build</tt> to build any missing native extensions
1041
- </p>
1042
- </li>
1043
- <li>
1044
- <p>
1045
- <tt>rake gems:refresh_specs</tt> to bring vendored gems created with Rails 2.1 into alignment with the Rails 2.2 way of storing them
1046
- </p>
1047
- </li>
1048
- </ul></div>
1049
- <div class="para"><p>You can unpack or install a single gem by specifying <tt>GEM=<em>gem_name</em></tt> on the command line.</p></div>
1050
- <div class="ilist"><ul>
1051
- <li>
1052
- <p>
1053
- Lead Contributor: <a href="http://github.com/al2o3cr">Matt Jones</a>
1054
- </p>
1055
- </li>
1056
- <li>
1057
- <p>
1058
- More information:
1059
- </p>
1060
- <div class="ilist"><ul>
1061
- <li>
1062
- <p>
1063
- <a href="http://ryandaigle.com/articles/2008/4/1/what-s-new-in-edge-rails-gem-dependencies">What's New in Edge Rails: Gem Dependencies</a>
1064
- </p>
1065
- </li>
1066
- <li>
1067
- <p>
1068
- <a href="http://afreshcup.com/2008/10/25/rails-212-and-22rc1-update-your-rubygems/">Rails 2.1.2 and 2.2RC1: Update Your RubyGems</a>
1069
- </p>
1070
- </li>
1071
- </ul></div>
1072
- </li>
1073
- </ul></div>
1074
- <h3 id="_other_railties_changes">10.2. Other Railties Changes</h3>
1075
- <div class="ilist"><ul>
1076
- <li>
1077
- <p>
1078
- If you're a fan of the <a href="http://code.macournoyer.com/thin/">Thin</a> web server, you'll be happy to know that <tt>script/server</tt> now supports Thin directly.
1079
- </p>
1080
- </li>
1081
- <li>
1082
- <p>
1083
- <tt>script/plugin install &lt;plugin&gt; -r &lt;revision&gt;</tt> now works with git-based as well as svn-based plugins.
1084
- </p>
1085
- </li>
1086
- <li>
1087
- <p>
1088
- <tt>script/console</tt> now supports a <tt>&#8212;debugger</tt> option
1089
- </p>
1090
- </li>
1091
- <li>
1092
- <p>
1093
- Instructions for setting up a continuous integration server to build Rails itself are included in the Rails source
1094
- </p>
1095
- </li>
1096
- <li>
1097
- <p>
1098
- <tt>rake notes:custom ANNOTATION=MYFLAG</tt> lets you list out custom annotations.
1099
- </p>
1100
- </li>
1101
- <li>
1102
- <p>
1103
- Wrapped <tt>Rails.env</tt> in <tt>StringInquirer</tt> so you can do <tt>Rails.env.development?</tt>
1104
- </p>
1105
- </li>
1106
- <li>
1107
- <p>
1108
- To eliminate deprecation warnings and properly handle gem dependencies, Rails now requires rubygems 1.3.1 or higher.
1109
- </p>
1110
- </li>
1111
- </ul></div>
1112
- </div>
1113
- <h2 id="_deprecated">11. Deprecated</h2>
1114
- <div class="sectionbody">
1115
- <div class="para"><p>A few pieces of older code are deprecated in this release:</p></div>
1116
- <div class="ilist"><ul>
1117
- <li>
1118
- <p>
1119
- <tt>Rails::SecretKeyGenerator</tt> has been replaced by <tt>ActiveSupport::SecureRandom</tt>
1120
- </p>
1121
- </li>
1122
- <li>
1123
- <p>
1124
- <tt>render_component</tt> is deprecated. There's a <a href="http://github.com/rails/render_component/tree/master">render_components plugin</a> available if you need this functionality.
1125
- </p>
1126
- </li>
1127
- <li>
1128
- <p>
1129
- Implicit local assignments when rendering partials has been deprecated.
1130
- </p>
1131
- </li>
1132
- </ul></div>
1133
- <div class="listingblock">
1134
- <div class="content"><!-- Generator: GNU source-highlight 2.9
1135
- by Lorenzo Bettini
1136
- http://www.lorenzobettini.it
1137
- http://www.gnu.org/software/src-highlite -->
1138
- <pre><tt><span style="font-weight: bold"><span style="color: #0000FF">def</span></span> partial_with_implicit_local_assignment
1139
- <span style="color: #009900">@customer</span> <span style="color: #990000">=</span> Customer<span style="color: #990000">.</span>new<span style="color: #990000">(</span><span style="color: #FF0000">"Marcel"</span><span style="color: #990000">)</span>
1140
- render <span style="color: #990000">:</span>partial <span style="color: #990000">=&gt;</span> <span style="color: #FF0000">"customer"</span>
1141
- <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
1142
- </tt></pre></div></div>
1143
- <div class="para"><p>Previously the above code made available a local variable called <tt>customer</tt> inside the partial <em>customer</em>. You should explicitly pass all the variables via :locals hash now.</p></div>
1144
- <div class="ilist"><ul>
1145
- <li>
1146
- <p>
1147
- <tt>country_select</tt> has been removed. See the <a href="http://www.rubyonrails.org/deprecation/list-of-countries">deprecation page</a> for more information and a plugin replacement.
1148
- </p>
1149
- </li>
1150
- <li>
1151
- <p>
1152
- <tt>ActiveRecord::Base.allow_concurrency</tt> no longer has any effect.
1153
- </p>
1154
- </li>
1155
- <li>
1156
- <p>
1157
- <tt>ActiveRecord::Errors.default_error_messages</tt> has been deprecated in favor of <tt>I18n.translate(<em>activerecord.errors.messages</em>)</tt>
1158
- </p>
1159
- </li>
1160
- <li>
1161
- <p>
1162
- The <tt>%s</tt> and <tt>%d</tt> interpolation syntax for internationalization is deprecated.
1163
- </p>
1164
- </li>
1165
- <li>
1166
- <p>
1167
- <tt>String#chars</tt> has been deprecated in favor of <tt>String#mb_chars</tt>.
1168
- </p>
1169
- </li>
1170
- <li>
1171
- <p>
1172
- Durations of fractional months or fractional years are deprecated. Use Ruby's core <tt>Date</tt> and <tt>Time</tt> class arithmetic instead.
1173
- </p>
1174
- </li>
1175
- </ul></div>
1176
- </div>
1177
- <h2 id="_credits">12. Credits</h2>
1178
- <div class="sectionbody">
1179
- <div class="para"><p>Release notes compiled by <a href="http://afreshcup.com">Mike Gunderloy</a></p></div>
1180
- </div>
1181
-
1182
- </div>
1183
- </div>
1184
- </body>
1185
- </html>