rails 4.0.0 → 4.0.1.rc1

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 (47) hide show
  1. checksums.yaml +4 -4
  2. data/guides/CHANGELOG.md +6 -0
  3. data/guides/assets/images/akshaysurve.jpg +0 -0
  4. data/guides/bug_report_templates/action_controller_gem.rb +42 -0
  5. data/guides/bug_report_templates/action_controller_master.rb +51 -0
  6. data/guides/code/getting_started/Gemfile +1 -1
  7. data/guides/code/getting_started/Gemfile.lock +76 -106
  8. data/guides/code/getting_started/app/controllers/comments_controller.rb +7 -1
  9. data/guides/code/getting_started/app/controllers/posts_controller.rb +8 -2
  10. data/guides/code/getting_started/app/views/posts/_form.html.erb +3 -3
  11. data/guides/code/getting_started/app/views/welcome/index.html.erb +1 -0
  12. data/guides/code/getting_started/test/fixtures/comments.yml +1 -1
  13. data/guides/code/getting_started/test/fixtures/posts.yml +1 -1
  14. data/guides/rails_guides.rb +20 -1
  15. data/guides/source/3_0_release_notes.md +0 -2
  16. data/guides/source/4_0_release_notes.md +30 -13
  17. data/guides/source/_welcome.html.erb +4 -1
  18. data/guides/source/action_controller_overview.md +2 -2
  19. data/guides/source/action_mailer_basics.md +6 -21
  20. data/guides/source/action_view_overview.md +2 -71
  21. data/guides/source/active_record_basics.md +9 -9
  22. data/guides/source/active_record_callbacks.md +1 -0
  23. data/guides/source/active_record_querying.md +45 -5
  24. data/guides/source/active_record_validations.md +6 -9
  25. data/guides/source/active_support_core_extensions.md +50 -1
  26. data/guides/source/asset_pipeline.md +10 -4
  27. data/guides/source/association_basics.md +8 -4
  28. data/guides/source/command_line.md +8 -8
  29. data/guides/source/configuring.md +4 -2
  30. data/guides/source/contributing_to_ruby_on_rails.md +60 -10
  31. data/guides/source/credits.html.erb +5 -1
  32. data/guides/source/debugging_rails_applications.md +4 -2
  33. data/guides/source/documents.yaml +7 -0
  34. data/guides/source/form_helpers.md +1 -1
  35. data/guides/source/generators.md +21 -6
  36. data/guides/source/getting_started.md +61 -54
  37. data/guides/source/i18n.md +7 -6
  38. data/guides/source/layout.html.erb +6 -8
  39. data/guides/source/layouts_and_rendering.md +4 -4
  40. data/guides/source/maintenance_policy.md +56 -0
  41. data/guides/source/migrations.md +13 -11
  42. data/guides/source/plugins.md +9 -3
  43. data/guides/source/rails_on_rack.md +5 -1
  44. data/guides/source/security.md +1 -1
  45. data/guides/source/testing.md +83 -23
  46. data/guides/source/upgrading_ruby_on_rails.md +36 -12
  47. metadata +17 -13
@@ -120,8 +120,8 @@ database only if the object is valid:
120
120
  * `update!`
121
121
 
122
122
  The bang versions (e.g. `save!`) raise an exception if the record is invalid.
123
- The non-bang versions don't: `save` and `update` return `false`,
124
- `create` and `update` just return the objects.
123
+ The non-bang versions don't, `save` and `update` return `false`,
124
+ `create` just returns the object.
125
125
 
126
126
  ### Skipping Validations
127
127
 
@@ -243,7 +243,7 @@ line of code you can add the same kind of validation to several attributes.
243
243
  All of them accept the `:on` and `:message` options, which define when the
244
244
  validation should be run and what message should be added to the `errors`
245
245
  collection if it fails, respectively. The `:on` option takes one of the values
246
- `:save` (the default), `:create` or `:update`. There is a default error
246
+ `:create` or `:update`. There is a default error
247
247
  message for each one of the validation helpers. These messages are used when
248
248
  the `:message` option isn't specified. Let's take a look at each one of the
249
249
  available helpers.
@@ -438,8 +438,6 @@ provide a personalized message or use `presence: true` instead. When
438
438
  `:in` or `:within` have a lower limit of 1, you should either provide a
439
439
  personalized message or call `presence` prior to `length`.
440
440
 
441
- The `size` helper is an alias for `length`.
442
-
443
441
  ### `numericality`
444
442
 
445
443
  This helper validates that your attributes have only numeric values. By
@@ -677,13 +675,13 @@ class GoodnessValidator
677
675
  def initialize(person)
678
676
  @person = person
679
677
  end
680
-
678
+
681
679
  def validate
682
680
  if some_complex_condition_involving_ivars_and_private_methods?
683
681
  @person.errors[:base] << "This person is evil"
684
682
  end
685
683
  end
686
-
684
+
687
685
  # …
688
686
  end
689
687
  ```
@@ -765,10 +763,9 @@ class Person < ActiveRecord::Base
765
763
  validates :age, numericality: true, on: :update
766
764
 
767
765
  # the default (validates on both create and update)
768
- validates :name, presence: true, on: :save
766
+ validates :name, presence: true
769
767
  end
770
768
  ```
771
- The last line is in review state and as of now, it is not running in any version of Rails 3.2.x as discussed in this [issue](https://github.com/rails/rails/issues/10248)
772
769
 
773
770
  Strict Validations
774
771
  ------------------
@@ -418,6 +418,14 @@ TIP: Since `with_options` forwards calls to its receiver they can be nested. Eac
418
418
 
419
419
  NOTE: Defined in `active_support/core_ext/object/with_options.rb`.
420
420
 
421
+ ### JSON support
422
+
423
+ Active Support provides a better implemention of `to_json` than the +json+ gem ordinarily provides for Ruby objects. This is because some classes, like +Hash+ and +OrderedHash+ needs special handling in order to provide a proper JSON representation.
424
+
425
+ Active Support also provides an implementation of `as_json` for the <tt>Process::Status</tt> class.
426
+
427
+ NOTE: Defined in `active_support/core_ext/object/to_json.rb`.
428
+
421
429
  ### Instance Variables
422
430
 
423
431
  Active Support provides several methods to ease access to instance variables.
@@ -439,6 +447,22 @@ C.new(0, 1).instance_values # => {"x" => 0, "y" => 1}
439
447
 
440
448
  NOTE: Defined in `active_support/core_ext/object/instance_variables.rb`.
441
449
 
450
+ #### `instance_variable_names`
451
+
452
+ The method `instance_variable_names` returns an array. Each name includes the "@" sign.
453
+
454
+ ```ruby
455
+ class C
456
+ def initialize(x, y)
457
+ @x, @y = x, y
458
+ end
459
+ end
460
+
461
+ C.new(0, 1).instance_variable_names # => ["@x", "@y"]
462
+ ```
463
+
464
+ NOTE: Defined in `active_support/core_ext/object/instance_variables.rb`.
465
+
442
466
  ### Silencing Warnings, Streams, and Exceptions
443
467
 
444
468
  The methods `silence_warnings` and `enable_warnings` change the value of `$VERBOSE` accordingly for the duration of their block, and reset it afterwards:
@@ -2011,8 +2035,33 @@ NOTE: Defined in `active_support/core_ext/integer/inflections.rb`.
2011
2035
 
2012
2036
  Extensions to `BigDecimal`
2013
2037
  --------------------------
2038
+ ### `to_s`
2014
2039
 
2015
- ...
2040
+ The method `to_s` is aliased to `to_formatted_s`. This provides a convenient way to display a BigDecimal value in floating-point notation:
2041
+
2042
+ ```ruby
2043
+ BigDecimal.new(5.00, 6).to_s # => "5.0"
2044
+ ```
2045
+
2046
+ ### `to_formatted_s`
2047
+
2048
+ Te method `to_formatted_s` provides a default specifier of "F". This means that a simple call to `to_formatted_s` or `to_s` will result in floating point representation instead of engineering notation:
2049
+
2050
+ ```ruby
2051
+ BigDecimal.new(5.00, 6).to_formatted_s # => "5.0"
2052
+ ```
2053
+
2054
+ and that symbol specifiers are also supported:
2055
+
2056
+ ```ruby
2057
+ BigDecimal.new(5.00, 6).to_formatted_s(:db) # => "5.0"
2058
+ ```
2059
+
2060
+ Engineering notation is still supported:
2061
+
2062
+ ```ruby
2063
+ BigDecimal.new(5.00, 6).to_formatted_s("e") # => "0.5E1"
2064
+ ```
2016
2065
 
2017
2066
  Extensions to `Enumerable`
2018
2067
  --------------------------
@@ -126,6 +126,11 @@ Pipeline assets can be placed inside an application in one of three locations: `
126
126
 
127
127
  * `vendor/assets` is for assets that are owned by outside entities, such as code for JavaScript plugins and CSS frameworks.
128
128
 
129
+ WARNING: If you are upgrading from Rails 3, please take into account that assets
130
+ under `lib/assets` or `vendor/assets` are available for inclusion via the
131
+ application manifests but no longer part of the precompile array. See
132
+ [Precompiling Assets](#precompiling-assets) for guidance.
133
+
129
134
  #### Search Paths
130
135
 
131
136
  When a file is referenced from a manifest or a helper, Sprockets searches the three default asset locations for it.
@@ -440,12 +445,13 @@ This links the folder specified in `config.assets.prefix` to `shared/assets`. If
440
445
 
441
446
  It is important that this folder is shared between deployments so that remotely cached pages that reference the old compiled assets still work for the life of the cached page.
442
447
 
443
- NOTE. If you are precompiling your assets locally, you can use `bundle install --without assets` on the server to avoid installing the assets gems (the gems in the assets group in the Gemfile).
444
-
445
- The default matcher for compiling files includes `application.js`, `application.css` and all non-JS/CSS files (this will include all image assets automatically):
448
+ The default matcher for compiling files includes `application.js`,
449
+ `application.css` and all non-JS/CSS files (this will include all image assets
450
+ automatically) from `app/assets` folders including your gems:
446
451
 
447
452
  ```ruby
448
- [ Proc.new { |path| !%w(.js .css).include?(File.extname(path)) }, /application.(css|js)$/ ]
453
+ [ Proc.new { |path, fn| fn =~ /app\/assets/ && !%w(.js .css).include?(File.extname(path)) },
454
+ /application.(css|js)$/ ]
449
455
  ```
450
456
 
451
457
  NOTE. The matcher (and other members of the precompile array; see below) is applied to final compiled file names. This means that anything that compiles to JS/CSS is excluded, as well as raw JS/CSS files; for example, `.coffee` and `.scss` files are **not** automatically included as they compile to JS/CSS.
@@ -261,7 +261,10 @@ With `through: :sections` specified, Rails will now understand:
261
261
 
262
262
  ### The `has_one :through` Association
263
263
 
264
- A `has_one :through` association sets up a one-to-one connection with another model. This association indicates that the declaring model can be matched with one instance of another model by proceeding _through_ a third model. For example, if each supplier has one account, and each account is associated with one account history, then the customer model could look like this:
264
+ A `has_one :through` association sets up a one-to-one connection with another model. This association indicates
265
+ that the declaring model can be matched with one instance of another model by proceeding _through_ a third model.
266
+ For example, if each supplier has one account, and each account is associated with one account history, then the
267
+ supplier model could look like this:
265
268
 
266
269
  ```ruby
267
270
  class Supplier < ActiveRecord::Base
@@ -1895,8 +1898,8 @@ While Rails uses intelligent defaults that will work well in most situations, th
1895
1898
 
1896
1899
  ```ruby
1897
1900
  class Parts < ActiveRecord::Base
1898
- has_and_belongs_to_many :assemblies, uniq: true,
1899
- read_only: true
1901
+ has_and_belongs_to_many :assemblies, autosave: true,
1902
+ readonly: true
1900
1903
  end
1901
1904
  ```
1902
1905
 
@@ -1908,6 +1911,7 @@ The `has_and_belongs_to_many` association supports these options:
1908
1911
  * `:foreign_key`
1909
1912
  * `:join_table`
1910
1913
  * `:validate`
1914
+ * `:readonly`
1911
1915
 
1912
1916
  ##### `:association_foreign_key`
1913
1917
 
@@ -2122,7 +2126,7 @@ You're not limited to the functionality that Rails automatically builds into ass
2122
2126
  class Customer < ActiveRecord::Base
2123
2127
  has_many :orders do
2124
2128
  def find_by_order_prefix(order_number)
2125
- find_by_region_id(order_number[0..2])
2129
+ find_by(region_id: order_number[0..2])
2126
2130
  end
2127
2131
  end
2128
2132
  end
@@ -64,7 +64,7 @@ With no further work, `rails server` will run our new shiny Rails app:
64
64
  $ cd commandsapp
65
65
  $ rails server
66
66
  => Booting WEBrick
67
- => Rails 3.2.3 application starting in development on http://0.0.0.0:3000
67
+ => Rails 4.0.0 application starting in development on http://0.0.0.0:3000
68
68
  => Call with -d to detach
69
69
  => Ctrl-C to shutdown server
70
70
  [2012-05-28 00:39:41] INFO WEBrick 1.3.1
@@ -289,7 +289,7 @@ If you wish to test out some code without changing any data, you can do that by
289
289
 
290
290
  ```bash
291
291
  $ rails console --sandbox
292
- Loading development environment in sandbox (Rails 3.2.3)
292
+ Loading development environment in sandbox (Rails 4.0.0)
293
293
  Any modifications you make will be rolled back on exit
294
294
  irb(main):001:0>
295
295
  ```
@@ -372,13 +372,13 @@ About your application's environment
372
372
  Ruby version 1.9.3 (x86_64-linux)
373
373
  RubyGems version 1.3.6
374
374
  Rack version 1.3
375
- Rails version 4.0.0.beta
375
+ Rails version 4.0.0
376
376
  JavaScript Runtime Node.js (V8)
377
- Active Record version 4.0.0.beta
378
- Action Pack version 4.0.0.beta
379
- Action Mailer version 4.0.0.beta
380
- Active Support version 4.0.0.beta
381
- Middleware ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
377
+ Active Record version 4.0.0
378
+ Action Pack version 4.0.0
379
+ Action Mailer version 4.0.0
380
+ Active Support version 4.0.0
381
+ Middleware Rack::Sendfile, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007ffd131a7c88>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::Migration::CheckPending, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::EncryptedCookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag
382
382
  Application root /home/foobar/commandsapp
383
383
  Environment development
384
384
  Database adapter sqlite3
@@ -101,6 +101,8 @@ These configuration methods are to be called on a `Rails::Railtie` object, such
101
101
 
102
102
  * `config.force_ssl` forces all requests to be under HTTPS protocol by using `ActionDispatch::SSL` middleware.
103
103
 
104
+ * `config.log_formatter` defines the formatter of the Rails logger. This option defaults to a instance of `ActiveSupport::Logger::SimpleFormatter` for all modes except production, where it defaults to `Logger::Formatter`.
105
+
104
106
  * `config.log_level` defines the verbosity of the Rails logger. This option defaults to `:debug` for all modes except production, where it defaults to `:info`.
105
107
 
106
108
  * `config.log_tags` accepts a list of methods that respond to `request` object. 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.
@@ -300,7 +302,7 @@ The schema dumper adds one additional configuration option:
300
302
 
301
303
  * `config.action_controller.permit_all_parameters` sets all the parameters for mass assignment to be permitted by default. The default value is `false`.
302
304
 
303
- * `config.action_controller.action_on_unpermitted_params` enables logging or raising an exception if parameters that are not explicitly permitted are found. Set to `:log` or `:raise` to enable. The default value is `:log` in development and test environments, and `false` in all other environments.
305
+ * `config.action_controller.action_on_unpermitted_parameters` enables logging or raising an exception if parameters that are not explicitly permitted are found. Set to `:log` or `:raise` to enable. The default value is `:log` in development and test environments, and `false` in all other environments.
304
306
 
305
307
  ### Configuring Action Dispatch
306
308
 
@@ -564,7 +566,7 @@ Rails has 5 initialization events which can be hooked into (listed in the order
564
566
 
565
567
  * `before_eager_load`: This is run directly before eager loading occurs, which is the default behavior for the `production` environment and not for the `development` environment.
566
568
 
567
- * `after_initialize`: Run directly after the initialization of the application, but before the application initializers are run.
569
+ * `after_initialize`: Run directly after the initialization of the application, after the application initializers in `config/initializers` are run.
568
570
 
569
571
  To define an event for these hooks, use the block syntax within a `Rails::Application`, `Rails::Railtie` or `Rails::Engine` subclass:
570
572
 
@@ -30,12 +30,14 @@ At the minimum, your issue report needs a title and descriptive text. But that's
30
30
 
31
31
  Then, don't get your hopes up! Unless you have a "Code Red, Mission Critical, the World is Coming to an End" kind of bug, you're creating this issue report in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the issue report will automatically see any activity or that others will jump to fix it. Creating an issue like this is mostly to help yourself start on the path of fixing the problem and for others to confirm it with an "I'm having this problem too" comment.
32
32
 
33
- ### Create a Self-Contained gist for Active Record Issues
33
+ ### Create a Self-Contained gist for Active Record and Action Controller Issues
34
34
 
35
- If you are filing a bug report for Active Record, please use
36
- [this template for gems](https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb)
35
+ If you are filing a bug report, please use
36
+ [Active Record template for gems](https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb) or
37
+ [Action Controller template for gems](https://github.com/rails/rails/blob/master/guides/bug_report_templates/action_controller_gem.rb)
37
38
  if the bug is found in a published gem, and
38
- [this template for master](https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb)
39
+ [Active Record template for master](https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb) or
40
+ [Action Controller template for master](https://github.com/rails/rails/blob/master/guides/bug_report_templates/action_controller_master.rb)
39
41
  if the bug happens in the master branch.
40
42
 
41
43
  ### Special Treatment for Security Issues
@@ -44,9 +46,28 @@ WARNING: Please do not report security vulnerabilities with public GitHub issue
44
46
 
45
47
  ### What about Feature Requests?
46
48
 
47
- Please don't put "feature request" items into GitHub Issues. If there's a new feature that you want to see added to Ruby on Rails, you'll need to write the code yourself - or convince someone else to partner with you to write the code. Later in this guide you'll find detailed instructions for proposing a patch to Ruby on Rails. If you enter a wishlist item in GitHub Issues with no code, you can expect it to be marked "invalid" as soon as it's reviewed.
48
-
49
- If you'd like feedback on an idea for a feature before doing the work for make a patch, please send an email to the [rails-core mailing list](https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core). You might get no response, which means that everyone is indifferent. You might find someone who's also interested in building that feature. You might get a "This won't be accepted." But it's the proper place to discuss new ideas. GitHub Issues are not a particularly good venue for the sometimes long and involved discussions new features require.
49
+ Please don't put "feature request" items into GitHub Issues. If there's a new
50
+ feature that you want to see added to Ruby on Rails, you'll need to write the
51
+ code yourself - or convince someone else to partner with you to write the code.
52
+ Later in this guide you'll find detailed instructions for proposing a patch to
53
+ Ruby on Rails. If you enter a wishlist item in GitHub Issues with no code, you
54
+ can expect it to be marked "invalid" as soon as it's reviewed.
55
+
56
+ Sometimes, the line between 'bug' and 'feature' is a hard one to draw.
57
+ Generally, a feature is anything that adds new behavior, while a bug is
58
+ anything that fixes already existing behavior that is mis-behaving. Sometimes,
59
+ the core team will have to make a judgement call. That said, the distinction
60
+ generally just affects which release your patch will get in to; we love feature
61
+ submissions! They just won't get backported to maintenance branches.
62
+
63
+ If you'd like feedback on an idea for a feature before doing the work for make
64
+ a patch, please send an email to the [rails-core mailing
65
+ list](https://groups.google.com/forum/?fromgroups#!forum/rubyonrails-core). You
66
+ might get no response, which means that everyone is indifferent. You might find
67
+ someone who's also interested in building that feature. You might get a "This
68
+ won't be accepted." But it's the proper place to discuss new ideas. GitHub
69
+ Issues are not a particularly good venue for the sometimes long and involved
70
+ discussions new features require.
50
71
 
51
72
  Setting Up a Development Environment
52
73
  ------------------------------------
@@ -184,7 +205,13 @@ Ruby on Rails has two main sets of documentation: the guides help you in learnin
184
205
 
185
206
  You can help improve the Rails guides by making them more coherent, consistent or readable, adding missing information, correcting factual errors, fixing typos, or bringing it up to date with the latest edge Rails. To get involved in the translation of Rails guides, please see [Translating Rails Guides](https://wiki.github.com/rails/docrails/translating-rails-guides).
186
207
 
187
- If you're confident about your changes, you can push them directly yourself via [docrails](https://github.com/rails/docrails). Docrails is a branch with an **open commit policy** and public write access. Commits to docrails are still reviewed, but this happens after they are pushed. Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
208
+ You can either open a pull request to [Rails](http://github.com/rails/rails) or
209
+ ask the [Rails core team](http://rubyonrails.org/core) for commit access on
210
+ [docrails](http://github.com/rails/docrails) if you contribute regularly.
211
+ Please do not open pull requests in docrails, if you'd like to get feedback on your
212
+ change, ask for it in [Rails](http://github.com/rails/rails) instead.
213
+
214
+ Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
188
215
 
189
216
  If you are unsure of the documentation changes, you can create an issue in the [Rails](https://github.com/rails/rails/issues) issues tracker on GitHub.
190
217
 
@@ -283,7 +310,13 @@ Your name can be added directly after the last word if you don't provide any cod
283
310
 
284
311
  ### Sanity Check
285
312
 
286
- You should not be the only person who looks at the code before you submit it. You know at least one other Rails developer, right? Show them what you’re doing and ask for feedback. Doing this in private before you push a patch out publicly is the “smoke test” for a patch: if you can’t convince one other developer of the beauty of your code, you’re unlikely to convince the core team either.
313
+ You should not be the only person who looks at the code before you submit it.
314
+ If you know someone else who uses Rails, try asking them if they'll check out
315
+ your work. If you don't know anyone else using Rails, try hopping into the IRC
316
+ room or posting about your idea to the rails-core mailing list. Doing this in
317
+ private before you push a patch out publicly is the “smoke test” for a patch:
318
+ if you can’t convince one other developer of the beauty of your code, you’re
319
+ unlikely to convince the core team either.
287
320
 
288
321
  ### Commit Your Changes
289
322
 
@@ -407,7 +440,24 @@ Fill in some details about your potential patch including a meaningful title. Wh
407
440
 
408
441
  ### Get some Feedback
409
442
 
410
- Now you need to get other people to look at your patch, just as you've looked at other people's patches. You can use the [rubyonrails-core mailing list](http://groups.google.com/group/rubyonrails-core/) or the #rails-contrib channel on IRC freenode for this. You might also try just talking to Rails developers that you know.
443
+ Most pull requests will go through a few iterations before they get merged.
444
+ Different contributors will sometimes have different opinions, and often
445
+ patches will need revised before they can get merged.
446
+
447
+ Some contributors to Rails have email notifications from GitHub turned on, but
448
+ others do not. Furthermore, (almost) everyone who works on Rails is a
449
+ volunteer, and so it may take a few days for you to get your first feedback on
450
+ a pull request. Don't despair! Sometimes it's quick, sometimes it's slow. Such
451
+ is the open source life.
452
+
453
+ If it's been over a week, and you haven't heard anything, you might want to try
454
+ and nudge things along. You can use the [rubyonrails-core mailing
455
+ list](http://groups.google.com/group/rubyonrails-core/) for this. You can also
456
+ leave another comment on the pull request.
457
+
458
+ While you're waiting for feedback on your pull request, open up a few other
459
+ pull requests and give someone else some! I'm sure they'll appreciate it in
460
+ the same way that you appreciate feedback on your patches.
411
461
 
412
462
  ### Iterate as Necessary
413
463
 
@@ -32,7 +32,7 @@ Ruby on Rails Guides: Credits
32
32
  <% end %>
33
33
 
34
34
  <%= author('Oscar Del Ben', 'oscardelben', 'oscardelben.jpg') do %>
35
- Oscar Del Ben is a software engineer at <a href="http://www.wildfireapp.com/">Wildfire</a>. He's a regular open source contributor (<a href="https://github.com/oscardelben">Github account</a>) and tweets regularly at <a href="https://twitter.com/oscardelben">@oscardelben</a>.
35
+ Oscar Del Ben is a software engineer at <a href="http://www.wildfireapp.com/">Wildfire</a>. He's a regular open source contributor (<a href="https://github.com/oscardelben">GitHub account</a>) and tweets regularly at <a href="https://twitter.com/oscardelben">@oscardelben</a>.
36
36
  <% end %>
37
37
 
38
38
  <%= author('Frederick Cheung', 'fcheung') do %>
@@ -74,3 +74,7 @@ Oscar Del Ben is a software engineer at <a href="http://www.wildfireapp.com/">Wi
74
74
  <%= author('Heiko Webers', 'hawe') do %>
75
75
  Heiko Webers is the founder of <a href="http://www.bauland42.de">bauland42</a>, a German web application security consulting and development company focused on Ruby on Rails. He blogs at the <a href="http://www.rorsecurity.info">Ruby on Rails Security Project</a>. After 10 years of desktop application development, Heiko has rarely looked back.
76
76
  <% end %>
77
+
78
+ <%= author('Akshay Surve', 'startupjockey', 'akshaysurve.jpg') do %>
79
+ Akshay Surve is the Founder at <a href="http://www.deltax.com">DeltaX</a>, hackathon specialist, a midnight code junkie and ocassionally writes prose. You can connect with him on <a href="https://twitter.com/akshaysurve">Twitter</a>, <a href="http://www.linkedin.com/in/akshaysurve">Linkedin</a>, <a href="http://www.akshaysurve.com/">Personal Blog</a> or <a href="http://www.quora.com/Akshay-Surve">Quora</a>.
80
+ <% end %>
@@ -248,7 +248,7 @@ Make sure you have started your web server with the option `--debugger`:
248
248
  ```bash
249
249
  $ rails server --debugger
250
250
  => Booting WEBrick
251
- => Rails 3.2.13 application starting on http://0.0.0.0:3000
251
+ => Rails 4.0.0 application starting on http://0.0.0.0:3000
252
252
  => Debugger enabled
253
253
  ...
254
254
  ```
@@ -504,7 +504,7 @@ TIP: You can use the debugger while using `rails console`. Just remember to `req
504
504
 
505
505
  ```
506
506
  $ rails console
507
- Loading development environment (Rails 3.2.13)
507
+ Loading development environment (Rails 4.0.0)
508
508
  >> require "debugger"
509
509
  => []
510
510
  >> author = Author.first
@@ -661,6 +661,8 @@ There are some Rails plugins to help you to find errors and debug your applicati
661
661
  * [Query Trace](https://github.com/ntalbott/query_trace/tree/master) Adds query origin tracing to your logs.
662
662
  * [Query Reviewer](https://github.com/nesquena/query_reviewer) This rails plugin not only runs "EXPLAIN" before each of your select queries in development, but provides a small DIV in the rendered output of each page with the summary of warnings for each query that it analyzed.
663
663
  * [Exception Notifier](https://github.com/smartinez87/exception_notification/tree/master) Provides a mailer object and a default set of templates for sending email notifications when errors occur in a Rails application.
664
+ * [Better Errors](https://github.com/charliesome/better_errors) Replaces the standard Rails error page with a new one containing more contextual information, like source code and variable inspection.
665
+ * [RailsPanel](https://github.com/dejan/rails_panel) Chrome extension for Rails development that will end your tailing of development.log. Have all information about your Rails app requests in the browser - in the Developer Tools panel. Provides insight to db/rendering/total times, parameter list, rendered views and more.
664
666
 
665
667
  References
666
668
  ----------
@@ -149,6 +149,13 @@
149
149
  name: Ruby on Rails Guides Guidelines
150
150
  url: ruby_on_rails_guides_guidelines.html
151
151
  description: This guide documents the Ruby on Rails guides guidelines.
152
+ -
153
+ name: Maintenance Policy
154
+ documents:
155
+ -
156
+ name: Maintenance Policy
157
+ url: maintenance_policy.html
158
+ description: What versions of Ruby on Rails are currently supported, and when to expect new versions.
152
159
  -
153
160
  name: Release Notes
154
161
  documents:
@@ -605,7 +605,7 @@ The object in the `params` hash is an instance of a subclass of IO. Depending on
605
605
  ```ruby
606
606
  def upload
607
607
  uploaded_io = params[:person][:picture]
608
- File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'w') do |file|
608
+ File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|
609
609
  file.write(uploaded_io.read)
610
610
  end
611
611
  end
@@ -35,7 +35,7 @@ $ rails generate helper --help
35
35
  Creating Your First Generator
36
36
  -----------------------------
37
37
 
38
- Since Rails 3.0, generators are built on top of [Thor](https://github.com/wycats/thor). Thor provides powerful options parsing and a great API for manipulating files. For instance, let's build a generator that creates an initializer file named `initializer.rb` inside `config/initializers`.
38
+ Since Rails 3.0, generators are built on top of [Thor](https://github.com/erikhuda/thor). Thor provides powerful options parsing and a great API for manipulating files. For instance, let's build a generator that creates an initializer file named `initializer.rb` inside `config/initializers`.
39
39
 
40
40
  The first step is to create a file at `lib/generators/initializer_generator.rb` with the following content:
41
41
 
@@ -47,7 +47,7 @@ class InitializerGenerator < Rails::Generators::Base
47
47
  end
48
48
  ```
49
49
 
50
- NOTE: `create_file` is a method provided by `Thor::Actions`. Documentation for `create_file` and other Thor methods can be found in [Thor's documentation](http://rdoc.info/github/wycats/thor/master/Thor/Actions.html)
50
+ NOTE: `create_file` is a method provided by `Thor::Actions`. Documentation for `create_file` and other Thor methods can be found in [Thor's documentation](http://rdoc.info/github/erikhuda/thor/master/Thor/Actions.html)
51
51
 
52
52
  Our new generator is quite simple: it inherits from `Rails::Generators::Base` and has one method definition. When a generator is invoked, each public method in the generator is executed sequentially in the order that it is defined. Finally, we invoke the `create_file` method that will create a file at the given destination with the given content. If you are familiar with the Rails Application Templates API, you'll feel right at home with the new generators API.
53
53
 
@@ -171,7 +171,7 @@ Before we customize our workflow, let's first see what our scaffold looks like:
171
171
  ```bash
172
172
  $ rails generate scaffold User name:string
173
173
  invoke active_record
174
- create db/migrate/20091120125558_create_users.rb
174
+ create db/migrate/20130924151154_create_users.rb
175
175
  create app/models/user.rb
176
176
  invoke test_unit
177
177
  create test/models/user_test.rb
@@ -193,6 +193,9 @@ $ rails generate scaffold User name:string
193
193
  create app/helpers/users_helper.rb
194
194
  invoke test_unit
195
195
  create test/helpers/users_helper_test.rb
196
+ invoke jbuilder
197
+ create app/views/users/index.json.jbuilder
198
+ create app/views/users/show.json.jbuilder
196
199
  invoke assets
197
200
  invoke coffee
198
201
  create app/assets/javascripts/users.js.coffee
@@ -221,11 +224,18 @@ To demonstrate this, we are going to create a new helper generator that simply a
221
224
 
222
225
  ```bash
223
226
  $ rails generate generator rails/my_helper
227
+ create lib/generators/rails/my_helper
228
+ create lib/generators/rails/my_helper/my_helper_generator.rb
229
+ create lib/generators/rails/my_helper/USAGE
230
+ create lib/generators/rails/my_helper/templates
224
231
  ```
225
232
 
226
- After that, we can delete both the `templates` directory and the `source_root` class method from our new generators, because we are not going to need them. So our new generator looks like the following:
233
+ After that, we can delete both the `templates` directory and the `source_root`
234
+ class method call from our new generator, because we are not going to need them.
235
+ Add the method below, so our generator looks like the following:
227
236
 
228
237
  ```ruby
238
+ # lib/generators/rails/my_helper/my_helper_generator.rb
229
239
  class Rails::MyHelperGenerator < Rails::Generators::NamedBase
230
240
  def create_helper_file
231
241
  create_file "app/helpers/#{file_name}_helper.rb", <<-FILE
@@ -241,6 +251,7 @@ We can try out our new generator by creating a helper for users:
241
251
 
242
252
  ```bash
243
253
  $ rails generate my_helper products
254
+ create app/helpers/products_helper.rb
244
255
  ```
245
256
 
246
257
  And it will generate the following helper file in `app/helpers`:
@@ -279,6 +290,7 @@ Since Rails 3.0, this is easy to do due to the hooks concept. Our new helper doe
279
290
  To do that, we can change the generator this way:
280
291
 
281
292
  ```ruby
293
+ # lib/generators/rails/my_helper/my_helper_generator.rb
282
294
  class Rails::MyHelperGenerator < Rails::Generators::NamedBase
283
295
  def create_helper_file
284
296
  create_file "app/helpers/#{file_name}_helper.rb", <<-FILE
@@ -351,7 +363,7 @@ Now, if you create a Comment scaffold, you will see that the shoulda generators
351
363
  ```bash
352
364
  $ rails generate scaffold Comment body:text
353
365
  invoke active_record
354
- create db/migrate/20091120151323_create_comments.rb
366
+ create db/migrate/20130924143118_create_comments.rb
355
367
  create app/models/comment.rb
356
368
  invoke shoulda
357
369
  create test/models/comment_test.rb
@@ -373,6 +385,9 @@ $ rails generate scaffold Comment body:text
373
385
  create app/helpers/comments_helper.rb
374
386
  invoke shoulda
375
387
  create test/helpers/comments_helper_test.rb
388
+ invoke jbuilder
389
+ create app/views/comments/index.json.jbuilder
390
+ create app/views/comments/show.json.jbuilder
376
391
  invoke assets
377
392
  invoke coffee
378
393
  create app/assets/javascripts/comments.js.coffee
@@ -422,7 +437,7 @@ Generator methods
422
437
 
423
438
  The following are methods available for both generators and templates for Rails.
424
439
 
425
- NOTE: Methods provided by Thor are not covered this guide and can be found in [Thor's documentation](http://rdoc.info/github/wycats/thor/master/Thor/Actions.html)
440
+ NOTE: Methods provided by Thor are not covered this guide and can be found in [Thor's documentation](http://rdoc.info/github/erikhuda/thor/master/Thor/Actions.html)
426
441
 
427
442
  ### `gem`
428
443