railties 3.2.0.rc1 → 3.2.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/CHANGELOG.md +6 -0
  2. data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
  3. data/guides/assets/stylesheets/kindle.css +11 -0
  4. data/guides/assets/stylesheets/main.css +8 -0
  5. data/guides/rails_guides/generator.rb +87 -20
  6. data/guides/rails_guides/helpers.rb +16 -0
  7. data/guides/source/3_2_release_notes.textile +452 -0
  8. data/guides/source/_license.html.erb +2 -0
  9. data/guides/source/_welcome.html.erb +19 -0
  10. data/guides/source/active_record_querying.textile +1 -1
  11. data/guides/source/active_support_core_extensions.textile +0 -10
  12. data/guides/source/asset_pipeline.textile +69 -67
  13. data/guides/source/caching_with_rails.textile +22 -0
  14. data/guides/source/documents.yaml +153 -0
  15. data/guides/source/getting_started.textile +2 -4
  16. data/guides/source/index.html.erb +14 -175
  17. data/guides/source/kindle/KINDLE.md +26 -0
  18. data/guides/source/kindle/copyright.html.erb +1 -0
  19. data/guides/source/kindle/layout.html.erb +27 -0
  20. data/guides/source/kindle/rails_guides.opf.erb +52 -0
  21. data/guides/source/kindle/toc.html.erb +24 -0
  22. data/guides/source/kindle/toc.ncx.erb +64 -0
  23. data/guides/source/kindle/welcome.html.erb +5 -0
  24. data/guides/source/layout.html.erb +11 -47
  25. data/guides/source/migrations.textile +1 -1
  26. data/lib/rails/application/bootstrap.rb +1 -1
  27. data/lib/rails/application/route_inspector.rb +10 -1
  28. data/lib/rails/generators/app_base.rb +3 -3
  29. data/lib/rails/generators/base.rb +3 -3
  30. data/lib/rails/generators/generated_attribute.rb +57 -3
  31. data/lib/rails/generators/named_base.rb +2 -3
  32. data/lib/rails/generators/rails/migration/migration_generator.rb +1 -1
  33. data/lib/rails/generators/rails/model/model_generator.rb +1 -1
  34. data/lib/rails/generators/rails/scaffold/USAGE +15 -9
  35. data/lib/rails/generators/test_case.rb +2 -2
  36. data/lib/rails/plugin.rb +1 -0
  37. data/lib/rails/tasks/documentation.rake +1 -1
  38. data/lib/rails/test_unit/sub_test_task.rb +36 -0
  39. data/lib/rails/test_unit/testing.rake +10 -50
  40. data/lib/rails/version.rb +1 -1
  41. metadata +132 -64
@@ -1,5 +1,11 @@
1
1
  ## Rails 3.2.0 (unreleased) ##
2
2
 
3
+ * Rails 2.3-style plugins in vendor/plugins are deprecated and will be removed in Rails 4.0. Move them out of vendor/plugins and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. *Santiago Pastorino*
4
+
5
+ * Guides are available as a single .mobi for the Kindle and free Kindle readers apps. *Michael Pearson & Xavier Noria*
6
+
7
+ * Allow scaffold/model/migration generators to accept a "index" and "uniq" modifiers, as in: "tracking_id:integer:uniq" in order to generate (unique) indexes. Some types also accept custom options, for instance, you can specify the precision and scale for decimals as "price:decimal{7,2}". *Dmitrii Samoilov*
8
+
3
9
  * Added `config.exceptions_app` to set the exceptions application invoked by the ShowException middleware when an exception happens. Defaults to `ActionDispatch::PublicExceptions.new(Rails.public_path)`. *José Valim*
4
10
 
5
11
  * Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting `config.reload_classes_only_on_change` to false. *José Valim*
@@ -0,0 +1,11 @@
1
+ p { text-indent: 0; }
2
+
3
+ p, H1, H2, H3, H4, H5, H6, H7, H8, table { margin-top: 1em;}
4
+
5
+ .pagebreak { page-break-before: always; }
6
+ #toc H3 {
7
+ text-indent: 1em;
8
+ }
9
+ #toc .document {
10
+ text-indent: 2em;
11
+ }
@@ -341,6 +341,14 @@ h6 {
341
341
  margin-top: 0.25em;
342
342
  }
343
343
 
344
+ #mainCol dd.kindle, #subCol dd.kindle {
345
+ background: #d5e9f6 url(../images/tab_info.gif) no-repeat left top;
346
+ border: none;
347
+ padding: 1.25em 1em 1.25em 48px;
348
+ margin-left: 0;
349
+ margin-top: 0.25em;
350
+ }
351
+
344
352
  #mainCol div.warning, #subCol dd.warning {
345
353
  background: #f9d9d8 url(../images/tab_red.gif) no-repeat left top;
346
354
  border: none;
@@ -47,6 +47,11 @@
47
47
  # Set to "1" to indicate generated guides should be marked as edge. This
48
48
  # inserts a badge and changes the preamble of the home page.
49
49
  #
50
+ # KINDLE
51
+ # Set to "1" to generate the .mobi with all the guides. The kindlegen
52
+ # executable must be in your PATH. You can get it for free from
53
+ # http://www.amazon.com/kindlepublishing
54
+ #
50
55
  # ---------------------------------------------------------------------------
51
56
 
52
57
  require 'set'
@@ -65,37 +70,81 @@ module RailsGuides
65
70
  class Generator
66
71
  attr_reader :guides_dir, :source_dir, :output_dir, :edge, :warnings, :all
67
72
 
68
- GUIDES_RE = /\.(?:textile|html\.erb)$/
73
+ GUIDES_RE = /\.(?:textile|erb)$/
69
74
 
70
75
  def initialize(output=nil)
71
- @lang = ENV['GUIDES_LANGUAGE']
76
+ set_flags_from_environment
77
+
78
+ if kindle?
79
+ check_for_kindlegen
80
+ register_kindle_mime_types
81
+ end
82
+
72
83
  initialize_dirs(output)
73
84
  create_output_dir_if_needed
74
- set_flags_from_environment
85
+ end
86
+
87
+ def set_flags_from_environment
88
+ @edge = ENV['EDGE'] == '1'
89
+ @warnings = ENV['WARNINGS'] == '1'
90
+ @all = ENV['ALL'] == '1'
91
+ @kindle = ENV['KINDLE'] == '1'
92
+ @version = ENV['RAILS_VERSION'] || `git rev-parse --short HEAD`.chomp
93
+ @lang = ENV['GUIDES_LANGUAGE']
94
+ end
95
+
96
+ def register_kindle_mime_types
97
+ Mime::Type.register_alias("application/xml", :opf, %w(opf))
98
+ Mime::Type.register_alias("application/xml", :ncx, %w(ncx))
75
99
  end
76
100
 
77
101
  def generate
78
102
  generate_guides
79
103
  copy_assets
104
+ generate_mobi if kindle?
80
105
  end
81
106
 
82
107
  private
108
+
109
+ def kindle?
110
+ @kindle
111
+ end
112
+
113
+ def check_for_kindlegen
114
+ if `which kindlegen`.blank?
115
+ raise "Can't create a kindle version without `kindlegen`."
116
+ end
117
+ end
118
+
119
+ def generate_mobi
120
+ opf = "#{output_dir}/rails_guides.opf"
121
+ out = "#{output_dir}/kindlegen.out"
122
+
123
+ system "kindlegen #{opf} -o #{mobi} > #{out} 2>&1"
124
+ puts "Guides compiled as Kindle book to #{mobi}"
125
+ puts "(kindlegen log at #{out})."
126
+ end
127
+
128
+ def mobi
129
+ "ruby_on_rails_guides_#@version%s.mobi" % (@lang.present? ? ".#@lang" : '')
130
+ end
131
+
83
132
  def initialize_dirs(output)
84
133
  @guides_dir = File.join(File.dirname(__FILE__), '..')
85
- @source_dir = File.join(@guides_dir, "source", @lang.to_s)
86
- @output_dir = output || File.join(@guides_dir, "output", @lang.to_s)
134
+ @source_dir = "#@guides_dir/source/#@lang"
135
+ @output_dir = if output
136
+ output
137
+ elsif kindle?
138
+ "#@guides_dir/output/kindle/#@lang"
139
+ else
140
+ "#@guides_dir/output/#@lang"
141
+ end.sub(%r</$>, '')
87
142
  end
88
143
 
89
144
  def create_output_dir_if_needed
90
145
  FileUtils.mkdir_p(output_dir)
91
146
  end
92
147
 
93
- def set_flags_from_environment
94
- @edge = ENV['EDGE'] == '1'
95
- @warnings = ENV['WARNINGS'] == '1'
96
- @all = ENV['ALL'] == '1'
97
- end
98
-
99
148
  def generate_guides
100
149
  guides_to_generate.each do |guide|
101
150
  output_file = output_file_for(guide)
@@ -105,6 +154,13 @@ module RailsGuides
105
154
 
106
155
  def guides_to_generate
107
156
  guides = Dir.entries(source_dir).grep(GUIDES_RE)
157
+
158
+ if kindle?
159
+ Dir.entries("#{source_dir}/kindle").grep(GUIDES_RE).map do |entry|
160
+ guides << "kindle/#{entry}"
161
+ end
162
+ end
163
+
108
164
  ENV.key?('ONLY') ? select_only(guides) : guides
109
165
  end
110
166
 
@@ -120,36 +176,47 @@ module RailsGuides
120
176
  end
121
177
 
122
178
  def output_file_for(guide)
123
- guide.sub(GUIDES_RE, '.html')
179
+ if guide =~/\.textile$/
180
+ guide.sub(/\.textile$/, '.html')
181
+ else
182
+ guide.sub(/\.erb$/, '')
183
+ end
184
+ end
185
+
186
+ def output_path_for(output_file)
187
+ File.join(output_dir, File.basename(output_file))
124
188
  end
125
189
 
126
190
  def generate?(source_file, output_file)
127
191
  fin = File.join(source_dir, source_file)
128
- fout = File.join(output_dir, output_file)
192
+ fout = output_path_for(output_file)
129
193
  all || !File.exists?(fout) || File.mtime(fout) < File.mtime(fin)
130
194
  end
131
195
 
132
196
  def generate_guide(guide, output_file)
133
- puts "Generating #{output_file}"
134
- File.open(File.join(output_dir, output_file), 'w') do |f|
135
- view = ActionView::Base.new(source_dir, :edge => edge)
197
+ output_path = output_path_for(output_file)
198
+ puts "Generating #{guide} as #{output_file}"
199
+ layout = kindle? ? 'kindle/layout' : 'layout'
200
+
201
+ File.open(output_path, 'w') do |f|
202
+ view = ActionView::Base.new(source_dir, :edge => @edge, :version => @version, :mobi => "kindle/#{mobi}")
136
203
  view.extend(Helpers)
137
204
 
138
- if guide =~ /\.html\.erb$/
205
+ if guide =~ /\.(\w+)\.erb$/
139
206
  # Generate the special pages like the home.
140
207
  # Passing a template handler in the template name is deprecated. So pass the file name without the extension.
141
- result = view.render(:layout => 'layout', :file => $`)
208
+ result = view.render(:layout => layout, :formats => [$1], :file => $`)
142
209
  else
143
210
  body = File.read(File.join(source_dir, guide))
144
211
  body = set_header_section(body, view)
145
212
  body = set_index(body, view)
146
213
 
147
- result = view.render(:layout => 'layout', :text => textile(body))
214
+ result = view.render(:layout => layout, :text => textile(body))
148
215
 
149
216
  warn_about_broken_links(result) if @warnings
150
217
  end
151
218
 
152
- f.write result
219
+ f.write(result)
153
220
  end
154
221
  end
155
222
 
@@ -12,6 +12,22 @@ module RailsGuides
12
12
  result
13
13
  end
14
14
 
15
+ def documents_by_section
16
+ @documents_by_section ||= YAML.load_file(File.expand_path('../../source/documents.yaml', __FILE__))
17
+ end
18
+
19
+ def documents_flat
20
+ documents_by_section.map {|section| section['documents']}.flatten
21
+ end
22
+
23
+ def finished_documents(documents)
24
+ documents.reject { |document| document['work_in_progress'] }
25
+ end
26
+
27
+ def docs_for_menu(position)
28
+ position == 'L' ? documents_by_section.to(3) : documents_by_section.from(4)
29
+ end
30
+
15
31
  def author(name, nick, image = 'credits_pic_blank.gif', &block)
16
32
  image = "images/#{image}"
17
33
 
@@ -0,0 +1,452 @@
1
+ h2. Ruby on Rails 3.2 Release Notes
2
+
3
+ Highlights in Rails 3.2:
4
+
5
+ * Faster Development Mode
6
+ * New Routing Engine
7
+ * Automatic Query Explains
8
+ * Tagged Logging
9
+
10
+ This release notes cover the major changes, but don't include every little bug fix and change. If you want to see everything, check out the "list of commits":https://github.com/rails/rails/commits/3-2-stable in the main Rails repository on GitHub.
11
+
12
+ endprologue.
13
+
14
+ h3. Upgrading to Rails 3.2
15
+
16
+ If you're upgrading an existing application, it's a great idea to have good test coverage before going in. You should also first upgrade to Rails 3.1 in case you haven't and make sure your application still runs as expected before attempting to update to Rails 3.2. Then take heed of the following changes:
17
+
18
+ h4. Rails 3.2 requires at least Ruby 1.8.7
19
+
20
+ Rails 3.2 requires Ruby 1.8.7 or higher. Support for all of the previous Ruby versions has been dropped officially and you should upgrade as early as possible. Rails 3.2 is also compatible with Ruby 1.9.2.
21
+
22
+ TIP: Note that Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails. Ruby Enterprise Edition have these fixed since release 1.8.7-2010.02. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults, so if you want to use 1.9.x, jump on 1.9.2 or 1.9.3 for smooth sailing.
23
+
24
+ h3. Creating a Rails 3.2 application
25
+
26
+ <shell>
27
+ # You should have the 'rails' rubygem installed
28
+ $ rails new myapp
29
+ $ cd myapp
30
+ </shell>
31
+
32
+ h4. Vendoring Gems
33
+
34
+ Rails now uses a +Gemfile+ in the application root to determine the gems you require for your application to start. This +Gemfile+ is processed by the "Bundler":https://github.com/carlhuda/bundler gem, which then installs all your dependencies. It can even install all the dependencies locally to your application so that it doesn't depend on the system gems.
35
+
36
+ More information: - "bundler homepage":http://gembundler.com
37
+
38
+ h4. Living on the Edge
39
+
40
+ +Bundler+ and +Gemfile+ makes freezing your Rails application easy as pie with the new dedicated +bundle+ command. If you want to bundle straight from the Git repository, you can pass the +--edge+ flag:
41
+
42
+ <shell>
43
+ $ rails new myapp --edge
44
+ </shell>
45
+
46
+ If you have a local checkout of the Rails repository and want to generate an application using that, you can pass the +--dev+ flag:
47
+
48
+ <shell>
49
+ $ ruby /path/to/rails/bin/rails new myapp --dev
50
+ </shell>
51
+
52
+ h3. Major Features
53
+
54
+ h4. Faster Development Mode & Routing
55
+
56
+ Rails 3.2 comes with a development mode that's noticeably faster. Inspired by "Active Reload":https://github.com/paneq/active_reload, Rails reloads classes only when files actually change. The performance gains are dramatic on a larger application. Route recognition also got a bunch faster thanks to the new "Journey":https://github.com/rails/journey engine.
57
+
58
+ h4. Automatic Query Explains
59
+
60
+ Rails 3.2 comes with a nice feature that explains queries generated by ARel by defining an +explain+ method in <tt>ActiveRecord::Relation</tt>. For example, you can run something like <tt>puts Person.active.limit(5).explain</tt> and the query ARel produces is explained. This allows to check for the proper indexes and further optimizations.
61
+
62
+ Queries that take more than half a second to run are *automatically* explained in the development mode. This threshold, of course, can be changed.
63
+
64
+ h4. Tagged Logging
65
+
66
+ When running a multi-user, multi-account application, it's a great help to be able to filter the log by who did what. TaggedLogging in Active Support helps in doing exactly that by stamping log lines with subdomains, request ids, and anything else to aid debugging of such applications.
67
+
68
+ h3. Railties
69
+
70
+
71
+ * Speed up development by only reloading classes if dependencies files changed. This can be turned off by setting <tt>config.reload_classes_only_on_change</tt> to false.
72
+
73
+ * New applications get a flag <tt>config.active_record.auto_explain_threshold_in_seconds</tt> in the environments configuration files. With a value of <tt>0.5</tt> in <tt>development.rb</tt> and commented out in <tt>production.rb</tt>. No mention in <tt>test.rb</tt>.
74
+
75
+ * Added <tt>config.exceptions_app</tt> to set the exceptions application invoked by the +ShowException+ middleware when an exception happens. Defaults to <tt>ActionDispatch::PublicExceptions.new(Rails.public_path)</tt>.
76
+
77
+ * Added a <tt>DebugExceptions</tt> middleware which contains features extracted from <tt>ShowExceptions</tt> middleware.
78
+
79
+ * Display mounted engines' routes in <tt>rake routes</tt>.
80
+
81
+ * Allow to change the loading order of railties with <tt>config.railties_order</tt> like:
82
+
83
+ <ruby>
84
+ config.railties_order = [Blog::Engine, :main_app, :all]
85
+ </ruby>
86
+
87
+ * Scaffold returns 204 No Content for API requests without content. This makes scaffold work with jQuery out of the box.
88
+
89
+ * Update Rails::Rack::Logger middleware to apply any tags set in config.log_tags to the newly ActiveSupport::TaggedLogging Rails.logger. This makes it easy to tag log lines with debug information like subdomain and request id -- both very helpful in debugging multi-user production applications
90
+
91
+ * Default options to +rails new+ can be set in <tt>~/.railsrc</tt>.
92
+
93
+ * Add an alias +d+ for +destroy+. This works for engines too.
94
+
95
+ * Attributes on scaffold and model generators default to string. This allows the following: <tt>rails g scaffold Post title body:text author</tt>
96
+
97
+ * Allow scaffold/model/migration generators to accept "index" and "uniq" modifiers. For example,
98
+
99
+ <ruby>
100
+ rails g scaffold Post title:string:index author:uniq price:decimal{7,2}
101
+ </ruby>
102
+
103
+ will create indexes for +title+ and +author+ with the latter being an unique index. Some types such as decimal accept custom options. In the example, +price+ will be a decimal column with precision and scale set to 7 and 2 respectively.
104
+
105
+ * Remove old plugin generator +rails generate plugin+ in favor of +rails plugin new+ command.
106
+
107
+ * Remove old <tt>config.paths.app.controller</tt> API in favor of <tt>config.paths["app/controller"]</tt>.
108
+
109
+ h4. Deprecations
110
+
111
+ * +Rails::Plugin+ is deprecated and will be removed in Rails 4.0. Instead of adding plugins to +vendor/plugins+ use gems or bundler with path or git dependencies.
112
+
113
+ h3. Action Pack
114
+
115
+ h4. Action Controller
116
+
117
+ * Make <tt>ActiveSupport::Benchmarkable</tt> a default module for <tt>ActionController::Base,</tt> so the <tt>#benchmark</tt> method is once again available in the controller context like it used to be.
118
+
119
+ * Added +:gzip+ option to +caches_page+. The default option can be configured globally using <tt>page_cache_compression</tt>.
120
+
121
+ * Rails will now use your default layout (such as "layouts/application") when you specify a layout with <tt>:only</tt> and <tt>:except</tt> condition, and those conditions fail.
122
+
123
+ <ruby>
124
+ class CarsController
125
+ layout 'single_car', :only => :show
126
+ end
127
+ </ruby>
128
+
129
+ Rails will use 'layouts/single_car' when a request comes in :show action, and use 'layouts/application' (or 'layouts/cars', if exists) when a request comes in for any other actions.
130
+
131
+ * form_for is changed to use "#{action}_#{as}" as the css class and id if +:as+ option is provided. Earlier versions used "#{as}_#{action}".
132
+
133
+ * <tt>ActionController::ParamsWrapper</tt> on ActiveRecord models now only wrap <tt>attr_accessible</tt> attributes if they were set. If not, only the attributes returned by the class method +attribute_names+ will be wrapped. This fixes the wrapping of nested attributes by adding them to +attr_accessible+.
134
+
135
+ * Log "Filter chain halted as CALLBACKNAME rendered or redirected" every time a before callback halts.
136
+
137
+ * <tt>ActionDispatch::ShowExceptions</tt> is refactored. The controller is responsible for choosing to show exceptions. It's possible to override +show_detailed_exceptions?+ in controllers to specify which requests should provide debugging information on errors.
138
+
139
+ * Responders now return 204 No Content for API requests without a response body (as in the new scaffold).
140
+
141
+ * <tt>ActionController::TestCase</tt> cookies is refactored. Assigning cookies for test cases should now use <tt>cookies[]</tt>
142
+
143
+ <ruby>
144
+ cookies[:email] = 'user@example.com'
145
+ get :index
146
+ assert_equal 'user@example.com', cookies[:email]
147
+ </ruby>
148
+
149
+ To clear the cookies, use +clear+.
150
+
151
+ <ruby>
152
+ cookies.clear
153
+ get :index
154
+ assert_nil cookies[:email]
155
+ </ruby>
156
+
157
+ We now no longer write out HTTP_COOKIE and the cookie jar is persistent between requests so if you need to manipulate the environment for your test you need to do it before the cookie jar is created.
158
+
159
+ * <tt>send_file</tt> now guesses the MIME type from the file extension if +:type+ is not provided.
160
+
161
+ * MIME type entries for PDF, ZIP and other formats were added.
162
+
163
+ * Allow fresh_when/stale? to take a record instead of an options hash.
164
+
165
+ * Changed log level of warning for missing CSRF token from <tt>:debug</tt> to <tt>:warn</tt>.
166
+
167
+ * Assets should use the request protocol by default or default to relative if no request is available.
168
+
169
+ h5. Deprecations
170
+
171
+ * Deprecated implied layout lookup in controllers whose parent had a explicit layout set:
172
+
173
+ <ruby>
174
+ class ApplicationController
175
+ layout "application"
176
+ end
177
+
178
+ class PostsController < ApplicationController
179
+ end
180
+ </ruby>
181
+
182
+ In the example above, Posts controller will no longer automatically look up for a posts layout. If you need this functionality you could either remove <tt>layout "application"</tt> from +ApplicationController+ or explicitly set it to +nil+ in +PostsController+.
183
+
184
+ h4. Action Dispatch
185
+
186
+ * Added <tt>ActionDispatch::RequestId</tt> middleware that'll make a unique X-Request-Id header available to the response and enables the <tt>ActionDispatch::Request#uuid</tt> method. This makes it easy to trace requests from end-to-end in the stack and to identify individual requests in mixed logs like Syslog.
187
+
188
+ * The <tt>ShowExceptions</tt> middleware now accepts a exceptions application that is responsible to render an exception when the application fails. The application is invoked with a copy of the exception in +env["action_dispatch.exception"]+ and with the <tt>PATH_INFO</tt> rewritten to the status code.
189
+
190
+ * Allow rescue responses to be configured through a railtie as in <tt>config.action_dispatch.rescue_responses</tt>.
191
+
192
+ h4. Action View
193
+
194
+ * Add +button_tag+ support to <tt>ActionView::Helpers::FormBuilder</tt>. This support mimics the default behavior of +submit_tag+.
195
+
196
+ <ruby>
197
+ <%= form_for @post do |f| %>
198
+ <%= f.button %>
199
+ <% end %>
200
+ </ruby>
201
+
202
+ * Date helpers accept a new option <tt>:use_two_digit_numbers => true</tt>, that renders select boxes for months and days with a leading zero without changing the respective values. For example, this is useful for displaying ISO8601-style dates such as '2011-08-01'.
203
+
204
+ * You can provide a namespace for your form to ensure uniqueness of id attributes on form elements. The namespace attribute will be prefixed with underscore on the generated HTML id.
205
+
206
+ <ruby>
207
+ <%= form_for(@offer, :namespace => 'namespace') do |f| %>
208
+ <%= f.label :version, 'Version' %>:
209
+ <%= f.text_field :version %>
210
+ <% end %>
211
+ </ruby>
212
+
213
+ * Limit the number of options for +select_year+ to 1000. Pass +:max_years_allowed+ option to set your own limit.
214
+
215
+ * +content_tag_for+ and +div_for+ can now take a collection of records. It will also yield the record as the first argument if you set a receiving argument in your block. So instead of having to do this:
216
+
217
+ <ruby>
218
+ @items.each do |item|
219
+ content_tag_for(:li, item) do
220
+ Title: <%= item.title %>
221
+ end
222
+ end
223
+ </ruby>
224
+
225
+ You can do this:
226
+
227
+ <ruby>
228
+ content_tag_for(:li, @items) do |item|
229
+ Title: <%= item.title %>
230
+ end
231
+ </ruby>
232
+
233
+ * Added +font_path+ helper method that computes the path to a font asset in <tt>public/fonts</tt>.
234
+
235
+ h5. Deprecations
236
+
237
+ * Passing formats or handlers to render :template and friends like <tt>render :template => "foo.html.erb"</tt> is deprecated. Instead, you can provide :handlers and :formats directly as an options: <tt> render :template => "foo", :formats => [:html, :js], :handlers => :erb</tt>.
238
+
239
+ h3. Active Record
240
+
241
+ * Implemented <tt>ActiveRecord::Relation#explain</tt>.
242
+
243
+ * Implements <tt>AR::Base.silence_auto_explain</tt> which allows the user to selectively disable automatic EXPLAINs within a block.
244
+
245
+ * Implements automatic EXPLAIN logging for slow queries. A new configuration parameter +config.active_record.auto_explain_threshold_in_seconds+ determines what's to be considered a slow query. Setting that to nil disables this feature. Defaults are 0.5 in development mode, and nil in test and production modes. As of this writing there's support for SQLite, MySQL (mysql2 adapter), and PostgreSQL.
246
+
247
+ * Added <tt>ActiveRecord::Base.store</tt> for declaring simple single-column key/value stores.
248
+
249
+ <ruby>
250
+ class User < ActiveRecord::Base
251
+ store :settings, accessors: [ :color, :homepage ]
252
+ end
253
+
254
+ u = User.new(color: 'black', homepage: '37signals.com')
255
+ u.color # Accessor stored attribute
256
+ u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor
257
+ </ruby>
258
+
259
+ * Added ability to run migrations only for a given scope, which allows to run migrations only from one engine (for example to revert changes from an engine that need to be removed).
260
+
261
+ <ruby>
262
+ rake db:migrate SCOPE=blog
263
+ </ruby>
264
+
265
+ * Migrations copied from engines are now scoped with engine's name, for example <tt>01_create_posts.blog.rb</tt>.
266
+
267
+ * Implemented <tt>ActiveRecord::Relation#pluck</tt> method that returns an array of column values directly from the underlying table. This also works with serialized attributes.
268
+
269
+ <ruby>
270
+ Client.where(:active => true).pluck(:id)
271
+ # SELECT id from clients where active = 1
272
+ </ruby>
273
+
274
+ * Generated association methods are created within a separate module to allow overriding and composition. For a class named MyModel, the module is named <tt>MyModel::GeneratedFeatureMethods</tt>. It is included into the model class immediately after the +generated_attributes_methods+ module defined in Active Model, so association methods override attribute methods of the same name.
275
+
276
+ * Add <tt>ActiveRecord::Relation#uniq</tt> for generating unique queries.
277
+
278
+ <ruby>
279
+ Client.select('DISTINCT name')
280
+ </ruby>
281
+
282
+ ..can be written as:
283
+
284
+ <ruby>
285
+ Client.select(:name).uniq
286
+ </ruby>
287
+
288
+ This also allows you to revert the uniqueness in a relation:
289
+
290
+ <ruby>
291
+ Client.select(:name).uniq.uniq(false)
292
+ </ruby>
293
+
294
+ * Support index sort order in SQLite, MySQL and PostgreSQL adapters.
295
+
296
+ * Allow the +:class_name+ option for associations to take a symbol in addition to a string. This is to avoid confusing newbies, and to be consistent with the fact that other options like :foreign_key already allow a symbol or a string.
297
+
298
+ <ruby>
299
+ has_many :clients, :class_name => :Client # Note that the symbol need to be capitalized
300
+ </ruby>
301
+
302
+ * In development mode, <tt>db:drop</tt> also drops the test database in order to be symmetric with <tt>db:create</tt>.
303
+
304
+ * Case-insensitive uniqueness validation avoids calling LOWER in MySQL when the column already uses a case-insensitive collation.
305
+
306
+ * Transactional fixtures enlist all active database connections. You can test models on different connections without disabling transactional fixtures.
307
+
308
+ * Add +first_or_create+, +first_or_create!+, +first_or_initialize+ methods to Active Record. This is a better approach over the old +find_or_create_by+ dynamic methods because it's clearer which arguments are used to find the record and which are used to create it.
309
+
310
+ <ruby>
311
+ User.where(:first_name => "Scarlett").first_or_create!(:last_name => "Johansson")
312
+ </ruby>
313
+
314
+ h4. Deprecations
315
+
316
+ * Automatic closure of connections in threads is deprecated. For example the following code is deprecated:
317
+
318
+ <ruby>
319
+ Thread.new { Post.find(1) }.join
320
+ </ruby>
321
+
322
+ It should be changed to close the database connection at the end of the thread:
323
+
324
+ <ruby>
325
+ Thread.new {
326
+ Post.find(1)
327
+ Post.connection.close
328
+ }.join
329
+ </ruby>
330
+
331
+ Only people who spawn threads in their application code need to worry about this change.
332
+
333
+ * The +set_table_name+, +set_inheritance_column+, +set_sequence_name+, +set_primary_key+, +set_locking_column+ methods are deprecated. Use an assignment method instead. For example, instead of +set_table_name+, use <tt>self.table_name=</tt>.
334
+
335
+ <ruby>
336
+ class Project < ActiveRecord::Base
337
+ self.table_name = "project"
338
+ end
339
+ </ruby>
340
+
341
+ Or define your own <tt>self.table_name</tt> method:
342
+
343
+ <ruby>
344
+ class Post < ActiveRecord::Base
345
+ def self.table_name
346
+ "special_" + super
347
+ end
348
+ end
349
+
350
+ Post.table_name # => "special_posts"
351
+
352
+ </ruby>
353
+
354
+ h3. Active Model
355
+
356
+ * Add <tt>ActiveModel::Errors#added?</tt> to check if a specific error has been added.
357
+
358
+ * Add ability to define strict validations with <tt>strict => true</tt> that always raises exception when fails.
359
+
360
+ * Provide mass_assignment_sanitizer as an easy API to replace the sanitizer behavior. Also support both :logger (default) and :strict sanitizer behavior.
361
+
362
+ h4. Deprecations
363
+
364
+ * Deprecated <tt>define_attr_method</tt> in <tt>ActiveModel::AttributeMethods</tt> because this only existed to support methods like +set_table_name+ in Active Record, which are themselves being deprecated.
365
+
366
+ * Deprecated <tt>Model.model_name.partial_path</tt> in favor of <tt>model.to_partial_path</tt>.
367
+
368
+ h3. Active Resource
369
+
370
+ * Redirect responses: 303 See Other and 307 Temporary Redirect now behave like 301 Moved Permanently and 302 Found.
371
+
372
+ h3. Active Support
373
+
374
+ * Added <tt>ActiveSupport:TaggedLogging</tt> that can wrap any standard +Logger+ class to provide tagging capabilities.
375
+
376
+ <ruby>
377
+ Logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
378
+
379
+ Logger.tagged("BCX") { Logger.info "Stuff" }
380
+ # Logs "[BCX] Stuff"
381
+
382
+ Logger.tagged("BCX", "Jason") { Logger.info "Stuff" }
383
+ # Logs "[BCX] [Jason] Stuff"
384
+
385
+ Logger.tagged("BCX") { Logger.tagged("Jason") { Logger.info "Stuff" } }
386
+ # Logs "[BCX] [Jason] Stuff"
387
+ </ruby>
388
+
389
+ * The +beginning_of_week+ method in +Date+, +Time+ and +DateTime+ accepts an optional argument representing the day in which the week is assumed to start.
390
+
391
+ * <tt>ActiveSupport::Notifications.subscribed</tt> provides subscriptions to events while a block runs.
392
+
393
+ * Defined new methods <tt>Module#qualified_const_defined?</tt>, <tt>Module#qualified_const_get</tt> and <tt>Module#qualified_const_set</tt> that are analogous to the corresponding methods in the standard API, but accept qualified constant names.
394
+
395
+ * Added +#deconstantize+ which complements +#demodulize+ in inflections. This removes the rightmost segment in a qualified constant name.
396
+
397
+ * Added <tt>safe_constantize</tt> that constantizes a string but returns +nil+ instead of raising an exception if the constant (or part of it) does not exist.
398
+
399
+ * <tt>ActiveSupport::OrderedHash</tt> is now marked as extractable when using <tt>Array#extract_options!</tt>.
400
+
401
+ * Added <tt>Array#prepend</tt> as an alias for <tt>Array#unshift</tt> and <tt>Array#append</tt> as an alias for <tt>Array#<<</tt>.
402
+
403
+ * The definition of a blank string for Ruby 1.9 has been extended to Unicode whitespace. Also, in Ruby 1.8 the ideographic space U+3000 is considered to be whitespace.
404
+
405
+ * The inflector understands acronyms.
406
+
407
+ * Added <tt>Time#all_day</tt>, <tt>Time#all_week</tt>, <tt>Time#all_quarter</tt> and <tt>Time#all_year</tt> as a way of generating ranges.
408
+
409
+ <ruby>
410
+ Event.where(:created_at => Time.now.all_week)
411
+ Event.where(:created_at => Time.now.all_day)
412
+ </ruby>
413
+
414
+ * Added <tt>instance_accessor: false</tt> as an option to <tt>Class#cattr_accessor</tt> and friends.
415
+
416
+ * <tt>ActiveSupport::OrderedHash</tt> now has different behavior for <tt>#each</tt> and <tt>#each_pair</tt> when given a block accepting its parameters with a splat.
417
+
418
+ * Added <tt>ActiveSupport::Cache::NullStore</tt> for use in development and testing.
419
+
420
+ * Removed <tt>ActiveSupport::SecureRandom</tt> in favor of <tt>SecureRandom</tt> from the standard library.
421
+
422
+ h4. Deprecations
423
+
424
+ * +ActiveSupport::Base64+ is deprecated in favor of <tt>::Base64</tt>.
425
+
426
+ * Deprecated <tt>ActiveSupport::Memoizable</tt> in favor of Ruby memoization pattern.
427
+
428
+ * <tt>Module#synchronize</tt> is deprecated with no replacement. Please use monitor from ruby's standard library.
429
+
430
+ * Deprecated <tt>ActiveSupport::MessageEncryptor#encrypt</tt> and <tt>ActiveSupport::MessageEncryptor#decrypt</tt>.
431
+
432
+ * <tt>ActiveSupport::BufferedLogger#silence</tt> is deprecated. If you want to squelch logs for a certain block, change the log level for that block.
433
+
434
+ * <tt>ActiveSupport::BufferedLogger#open_log</tt> is deprecated. This method should not have been public in the first place.
435
+
436
+ * <tt>ActiveSupport::BufferedLogger's</tt> behavior of automatically creating the directory for your log file is deprecated. Please make sure to create the directory for your log file before instantiating.
437
+
438
+ * <tt>ActiveSupport::BufferedLogger#auto_flushing</tt> is deprecated. Either set the sync level on the underlying file handle like this. Or tune your filesystem. The FS cache is now what controls flushing.
439
+
440
+ <ruby>
441
+ f = File.open('foo.log', 'w')
442
+ f.sync = true
443
+ ActiveSupport::BufferedLogger.new f
444
+ </ruby>
445
+
446
+ * <tt>ActiveSupport::BufferedLogger#flush</tt> is deprecated. Set sync on your filehandle, or tune your filesystem.
447
+
448
+ h3. Credits
449
+
450
+ See the "full list of contributors to Rails":http://contributors.rubyonrails.org/ for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.
451
+
452
+ Rails 3.2 Release Notes were compiled by "Vijay Dev":https://github.com/vijaydev.