rails 4.0.0.beta1 → 4.0.0.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.
- checksums.yaml +4 -4
- data/README.md +78 -0
- data/guides/CHANGELOG.md +3 -0
- data/guides/assets/images/getting_started/unknown_action_create_for_posts.png +0 -0
- data/guides/bug_report_templates/active_record_gem.rb +37 -0
- data/guides/bug_report_templates/active_record_master.rb +48 -0
- data/guides/code/getting_started/Gemfile +16 -11
- data/guides/code/getting_started/app/controllers/comments_controller.rb +2 -2
- data/guides/code/getting_started/app/controllers/posts_controller.rb +2 -2
- data/guides/code/getting_started/config/application.rb +3 -2
- data/guides/code/getting_started/config/initializers/session_store.rb +1 -1
- data/guides/code/getting_started/config/routes.rb +2 -2
- data/guides/code/getting_started/public/404.html +41 -10
- data/guides/code/getting_started/public/422.html +42 -10
- data/guides/code/getting_started/public/500.html +41 -10
- data/guides/rails_guides/markdown/renderer.rb +1 -1
- data/guides/source/2_2_release_notes.md +15 -15
- data/guides/source/4_0_release_notes.md +1 -7
- data/guides/source/action_controller_overview.md +176 -22
- data/guides/source/action_mailer_basics.md +246 -141
- data/guides/source/action_view_overview.md +3 -8
- data/guides/source/active_record_basics.md +98 -95
- data/guides/source/active_record_querying.md +90 -17
- data/guides/source/active_record_validations.md +41 -0
- data/guides/source/active_support_core_extensions.md +23 -3
- data/guides/source/active_support_instrumentation.md +6 -6
- data/guides/source/asset_pipeline.md +1 -1
- data/guides/source/association_basics.md +34 -10
- data/guides/source/caching_with_rails.md +2 -7
- data/guides/source/command_line.md +7 -7
- data/guides/source/configuring.md +3 -3
- data/guides/source/contributing_to_ruby_on_rails.md +38 -5
- data/guides/source/credits.html.erb +1 -1
- data/guides/source/debugging_rails_applications.md +19 -22
- data/guides/source/development_dependencies_install.md +2 -2
- data/guides/source/documents.yaml +5 -1
- data/guides/source/engines.md +21 -16
- data/guides/source/form_helpers.md +28 -7
- data/guides/source/generators.md +2 -2
- data/guides/source/getting_started.md +14 -13
- data/guides/source/i18n.md +22 -0
- data/guides/source/initialization.md +1 -1
- data/guides/source/layouts_and_rendering.md +60 -4
- data/guides/source/migrations.md +27 -2
- data/guides/source/rails_application_templates.md +11 -11
- data/guides/source/rails_on_rack.md +9 -6
- data/guides/source/routing.md +19 -3
- data/guides/source/ruby_on_rails_guides_guidelines.md +1 -1
- data/guides/source/security.md +2 -2
- data/guides/source/testing.md +106 -85
- data/guides/source/upgrading_ruby_on_rails.md +112 -9
- data/guides/source/working_with_javascript_in_rails.md +1 -0
- metadata +17 -16
- data/README.rdoc +0 -77
- data/guides/code/getting_started/app/assets/images/rails.png +0 -0
@@ -530,6 +530,47 @@ field you should use `validates :field_name, inclusion: { in: [true, false] }`.
|
|
530
530
|
|
531
531
|
The default error message is _"can't be empty"_.
|
532
532
|
|
533
|
+
### `absence`
|
534
|
+
|
535
|
+
This helper validates that the specified attributes are absent. It uses the
|
536
|
+
`present?` method to check if the value is not either nil or a blank string, that
|
537
|
+
is, a string that is either empty or consists of whitespace.
|
538
|
+
|
539
|
+
```ruby
|
540
|
+
class Person < ActiveRecord::Base
|
541
|
+
validates :name, :login, :email, absence: true
|
542
|
+
end
|
543
|
+
```
|
544
|
+
|
545
|
+
If you want to be sure that an association is absent, you'll need to test
|
546
|
+
whether the associated object itself is absent, and not the foreign key used
|
547
|
+
to map the association.
|
548
|
+
|
549
|
+
```ruby
|
550
|
+
class LineItem < ActiveRecord::Base
|
551
|
+
belongs_to :order
|
552
|
+
validates :order, absence: true
|
553
|
+
end
|
554
|
+
```
|
555
|
+
|
556
|
+
In order to validate associated records whose absence is required, you must
|
557
|
+
specify the `:inverse_of` option for the association:
|
558
|
+
|
559
|
+
```ruby
|
560
|
+
class Order < ActiveRecord::Base
|
561
|
+
has_many :line_items, inverse_of: :order
|
562
|
+
end
|
563
|
+
```
|
564
|
+
|
565
|
+
If you validate the absence of an object associated via a `has_one` or
|
566
|
+
`has_many` relationship, it will check that the object is neither `present?` nor
|
567
|
+
`marked_for_destruction?`.
|
568
|
+
|
569
|
+
Since `false.present?` is false, if you want to validate the absence of a boolean
|
570
|
+
field you should use `validates :field_name, exclusion: { in: [true, false] }`.
|
571
|
+
|
572
|
+
The default error message is _"must be blank"_.
|
573
|
+
|
533
574
|
### `uniqueness`
|
534
575
|
|
535
576
|
This helper validates that the attribute's value is unique right before the
|
@@ -1039,6 +1039,8 @@ For convenience `class_attribute` also defines an instance predicate which is th
|
|
1039
1039
|
|
1040
1040
|
When `:instance_reader` is `false`, the instance predicate returns a `NoMethodError` just like the reader method.
|
1041
1041
|
|
1042
|
+
If you do not want the instance predicate, pass `instance_predicate: false` and it will not be defined.
|
1043
|
+
|
1042
1044
|
NOTE: Defined in `active_support/core_ext/class/attribute.rb`
|
1043
1045
|
|
1044
1046
|
#### `cattr_reader`, `cattr_writer`, and `cattr_accessor`
|
@@ -1344,7 +1346,7 @@ The second argument, `indent_string`, specifies which indent string to use. The
|
|
1344
1346
|
"foo".indent(2, "\t") # => "\t\tfoo"
|
1345
1347
|
```
|
1346
1348
|
|
1347
|
-
While `indent_string` is
|
1349
|
+
While `indent_string` is typically one space or tab, it may be any string.
|
1348
1350
|
|
1349
1351
|
The third argument, `indent_empty_lines`, is a flag that says whether empty lines should be indented. Default is false.
|
1350
1352
|
|
@@ -2198,7 +2200,7 @@ This method accepts three options:
|
|
2198
2200
|
* `:words_connector`: What is used to join the elements of arrays with 3 or more elements, except for the last two. Default is ", ".
|
2199
2201
|
* `:last_word_connector`: What is used to join the last items of an array with 3 or more elements. Default is ", and ".
|
2200
2202
|
|
2201
|
-
The defaults for these options can be
|
2203
|
+
The defaults for these options can be localized, their keys are:
|
2202
2204
|
|
2203
2205
|
| Option | I18n key |
|
2204
2206
|
| ---------------------- | ----------------------------------- |
|
@@ -3320,7 +3322,25 @@ date.end_of_hour # => Mon Jun 07 19:59:59 +0200 2010
|
|
3320
3322
|
|
3321
3323
|
`beginning_of_hour` is aliased to `at_beginning_of_hour`.
|
3322
3324
|
|
3323
|
-
|
3325
|
+
##### `beginning_of_minute`, `end_of_minute`
|
3326
|
+
|
3327
|
+
The method `beginning_of_minute` returns a timestamp at the beginning of the minute (hh:mm:00):
|
3328
|
+
|
3329
|
+
```ruby
|
3330
|
+
date = DateTime.new(2010, 6, 7, 19, 55, 25)
|
3331
|
+
date.beginning_of_minute # => Mon Jun 07 19:55:00 +0200 2010
|
3332
|
+
```
|
3333
|
+
|
3334
|
+
The method `end_of_minute` returns a timestamp at the end of the minute (hh:mm:59):
|
3335
|
+
|
3336
|
+
```ruby
|
3337
|
+
date = DateTime.new(2010, 6, 7, 19, 55, 25)
|
3338
|
+
date.end_of_minute # => Mon Jun 07 19:55:59 +0200 2010
|
3339
|
+
```
|
3340
|
+
|
3341
|
+
`beginning_of_minute` is aliased to `at_beginning_of_minute`.
|
3342
|
+
|
3343
|
+
INFO: `beginning_of_hour`, `end_of_hour`, `beginning_of_minute` and `end_of_minute` are implemented for `Time` and `DateTime` but **not** `Date` as it does not make sense to request the beginning or end of an hour or minute on a `Date` instance.
|
3324
3344
|
|
3325
3345
|
##### `ago`, `since`
|
3326
3346
|
|
@@ -273,7 +273,7 @@ Action Mailer
|
|
273
273
|
to: ["users@rails.com", "ddh@rails.com"],
|
274
274
|
from: ["me@rails.com"],
|
275
275
|
date: Sat, 10 Mar 2012 14:18:09 +0100,
|
276
|
-
mail: "..." #
|
276
|
+
mail: "..." # omitted for brevity
|
277
277
|
}
|
278
278
|
```
|
279
279
|
|
@@ -299,7 +299,7 @@ Action Mailer
|
|
299
299
|
to: ["users@rails.com", "ddh@rails.com"],
|
300
300
|
from: ["me@rails.com"],
|
301
301
|
date: Sat, 10 Mar 2012 14:18:09 +0100,
|
302
|
-
mail: "..." #
|
302
|
+
mail: "..." # omitted for brevity
|
303
303
|
}
|
304
304
|
```
|
305
305
|
|
@@ -428,7 +428,7 @@ end
|
|
428
428
|
```
|
429
429
|
|
430
430
|
Defining all those block arguments each time can be tedious. You can easily create an `ActiveSupport::Notifications::Event`
|
431
|
-
from block
|
431
|
+
from block arguments like this:
|
432
432
|
|
433
433
|
```ruby
|
434
434
|
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
|
@@ -442,7 +442,7 @@ ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*a
|
|
442
442
|
end
|
443
443
|
```
|
444
444
|
|
445
|
-
Most times you only care about the data itself. Here is a
|
445
|
+
Most times you only care about the data itself. Here is a shortcut to just get the data.
|
446
446
|
|
447
447
|
```ruby
|
448
448
|
ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*args|
|
@@ -450,7 +450,7 @@ ActiveSupport::Notifications.subscribe "process_action.action_controller" do |*a
|
|
450
450
|
data # { extra: :information }
|
451
451
|
```
|
452
452
|
|
453
|
-
You may also subscribe to events matching a regular
|
453
|
+
You may also subscribe to events matching a regular expression. This enables you to subscribe to
|
454
454
|
multiple events at once. Here's you could subscribe to everything from `ActionController`.
|
455
455
|
|
456
456
|
```ruby
|
@@ -465,7 +465,7 @@ Creating custom events
|
|
465
465
|
Adding your own events is easy as well. `ActiveSupport::Notifications` will take care of
|
466
466
|
all the heavy lifting for you. Simply call `instrument` with a `name`, `payload` and a block.
|
467
467
|
The notification will be sent after the block returns. `ActiveSupport` will generate the start and end times
|
468
|
-
as well as the unique ID. All data passed into the `
|
468
|
+
as well as the unique ID. All data passed into the `instrument` call will make it into the payload.
|
469
469
|
|
470
470
|
Here's an example:
|
471
471
|
|
@@ -572,7 +572,7 @@ end
|
|
572
572
|
These need to be backed up by a migration to create the `assemblies_parts` table. This table should be created without a primary key:
|
573
573
|
|
574
574
|
```ruby
|
575
|
-
class
|
575
|
+
class CreateAssembliesPartsJoinTable < ActiveRecord::Migration
|
576
576
|
def change
|
577
577
|
create_table :assemblies_parts, id: false do |t|
|
578
578
|
t.integer :assembly_id
|
@@ -845,7 +845,7 @@ Counter cache columns are added to the containing model's list of read-only attr
|
|
845
845
|
|
846
846
|
##### `:dependent`
|
847
847
|
|
848
|
-
If you set the `:dependent` option to `:destroy`, then deleting this object will call the `destroy` method on the associated object to delete that object. If you set the `:dependent` option to `:delete`, then deleting this object will delete the associated object _without_ calling its `destroy` method.
|
848
|
+
If you set the `:dependent` option to `:destroy`, then deleting this object will call the `destroy` method on the associated object to delete that object. If you set the `:dependent` option to `:delete`, then deleting this object will delete the associated object _without_ calling its `destroy` method. If you set the `:dependent` option to `:restrict`, then attempting to delete this object will result in a `ActiveRecord::DeleteRestrictionError` if there are any associated objects.
|
849
849
|
|
850
850
|
WARNING: You should not specify this option on a `belongs_to` association that is connected with a `has_many` association on the other class. Doing so can lead to orphaned records in your database.
|
851
851
|
|
@@ -1109,7 +1109,7 @@ end
|
|
1109
1109
|
Controls what happens to the associated object when its owner is destroyed:
|
1110
1110
|
|
1111
1111
|
* `:destroy` causes the associated object to also be destroyed
|
1112
|
-
* `:delete` causes the
|
1112
|
+
* `:delete` causes the associated object to be deleted directly from the database (so callbacks will not execute)
|
1113
1113
|
* `:nullify` causes the foreign key to be set to `NULL`. Callbacks are not executed.
|
1114
1114
|
* `:restrict_with_exception` causes an exception to be raised if there is an associated record
|
1115
1115
|
* `:restrict_with_error` causes an error to be added to the owner if there is an associated object
|
@@ -1463,7 +1463,7 @@ end
|
|
1463
1463
|
Controls what happens to the associated objects when their owner is destroyed:
|
1464
1464
|
|
1465
1465
|
* `:destroy` causes all the associated objects to also be destroyed
|
1466
|
-
* `:delete_all` causes all the
|
1466
|
+
* `:delete_all` causes all the associated objects to be deleted directly from the database (so callbacks will not execute)
|
1467
1467
|
* `:nullify` causes the foreign keys to be set to `NULL`. Callbacks are not executed.
|
1468
1468
|
* `:restrict_with_exception` causes an exception to be raised if there are any associated records
|
1469
1469
|
* `:restrict_with_error` causes an error to be added to the owner if there are any associated objects
|
@@ -1648,9 +1648,10 @@ The `select` method lets you override the SQL `SELECT` clause that is used to re
|
|
1648
1648
|
|
1649
1649
|
WARNING: If you specify your own `select`, be sure to include the primary key and foreign key columns of the associated model. If you do not, Rails will throw an error.
|
1650
1650
|
|
1651
|
-
##### `
|
1651
|
+
##### `distinct`
|
1652
1652
|
|
1653
|
-
Use the `
|
1653
|
+
Use the `distinct` method to keep the collection free of duplicates. This is
|
1654
|
+
mostly useful together with the `:through` option.
|
1654
1655
|
|
1655
1656
|
```ruby
|
1656
1657
|
class Person < ActiveRecord::Base
|
@@ -1666,14 +1667,15 @@ person.posts.inspect # => [#<Post id: 5, name: "a1">, #<Post id: 5, name: "a1">]
|
|
1666
1667
|
Reading.all.inspect # => [#<Reading id: 12, person_id: 5, post_id: 5>, #<Reading id: 13, person_id: 5, post_id: 5>]
|
1667
1668
|
```
|
1668
1669
|
|
1669
|
-
In the above case there are two readings and `person.posts` brings out both of
|
1670
|
+
In the above case there are two readings and `person.posts` brings out both of
|
1671
|
+
them even though these records are pointing to the same post.
|
1670
1672
|
|
1671
|
-
Now let's set `
|
1673
|
+
Now let's set `distinct`:
|
1672
1674
|
|
1673
1675
|
```ruby
|
1674
1676
|
class Person
|
1675
1677
|
has_many :readings
|
1676
|
-
has_many :posts, -> {
|
1678
|
+
has_many :posts, -> { distinct }, through: :readings
|
1677
1679
|
end
|
1678
1680
|
|
1679
1681
|
person = Person.create(name: 'Honda')
|
@@ -1684,7 +1686,29 @@ person.posts.inspect # => [#<Post id: 7, name: "a1">]
|
|
1684
1686
|
Reading.all.inspect # => [#<Reading id: 16, person_id: 7, post_id: 7>, #<Reading id: 17, person_id: 7, post_id: 7>]
|
1685
1687
|
```
|
1686
1688
|
|
1687
|
-
In the above case there are still two readings. However `person.posts` shows
|
1689
|
+
In the above case there are still two readings. However `person.posts` shows
|
1690
|
+
only one post because the collection loads only unique records.
|
1691
|
+
|
1692
|
+
If you want to make sure that, upon insertion, all of the records in the
|
1693
|
+
persisted association are distinct (so that you can be sure that when you
|
1694
|
+
inspect the association that you will never find duplicate records), you should
|
1695
|
+
add a unique index on the table itself. For example, if you have a table named
|
1696
|
+
``person_posts`` and you want to make sure all the posts are unique, you could
|
1697
|
+
add the following in a migration:
|
1698
|
+
|
1699
|
+
```ruby
|
1700
|
+
add_index :person_posts, :post, :unique => true
|
1701
|
+
```
|
1702
|
+
|
1703
|
+
Note that checking for uniqueness using something like ``include?`` is subject
|
1704
|
+
to race conditions. Do not attempt to use ``include?`` to enforce distinctness
|
1705
|
+
in an association. For instance, using the post example from above, the
|
1706
|
+
following code would be racy because multiple users could be attempting this
|
1707
|
+
at the same time:
|
1708
|
+
|
1709
|
+
```ruby
|
1710
|
+
person.posts << post unless person.posts.include?(post)
|
1711
|
+
```
|
1688
1712
|
|
1689
1713
|
#### When are Objects Saved?
|
1690
1714
|
|
@@ -5,8 +5,8 @@ This guide will teach you what you need to know about avoiding that expensive ro
|
|
5
5
|
|
6
6
|
After reading this guide, you will know:
|
7
7
|
|
8
|
-
* Page
|
9
|
-
*
|
8
|
+
* Page and action caching (moved to separate gems as of Rails 4).
|
9
|
+
* Fragment caching.
|
10
10
|
* Alternative cache stores.
|
11
11
|
* Conditional GET support.
|
12
12
|
|
@@ -343,8 +343,3 @@ class ProductsController < ApplicationController
|
|
343
343
|
end
|
344
344
|
end
|
345
345
|
```
|
346
|
-
|
347
|
-
Further reading
|
348
|
-
---------------
|
349
|
-
|
350
|
-
* [Scaling Rails Screencasts](http://railslab.newrelic.com/scaling-rails)
|
@@ -82,7 +82,7 @@ The server can be run on a different port using the `-p` option. The default dev
|
|
82
82
|
$ rails server -e production -p 4000
|
83
83
|
```
|
84
84
|
|
85
|
-
The `-b` option binds Rails to the specified
|
85
|
+
The `-b` option binds Rails to the specified IP, by default it is 0.0.0.0. You can run a server as a daemon by passing a `-d` option.
|
86
86
|
|
87
87
|
### `rails generate`
|
88
88
|
|
@@ -414,7 +414,7 @@ app/controllers/admin/users_controller.rb:
|
|
414
414
|
* [ 20] [TODO] any other way to do this?
|
415
415
|
* [132] [FIXME] high priority for next deploy
|
416
416
|
|
417
|
-
app/
|
417
|
+
app/models/school.rb:
|
418
418
|
* [ 13] [OPTIMIZE] refactor this code to make it faster
|
419
419
|
* [ 17] [FIXME]
|
420
420
|
```
|
@@ -427,7 +427,7 @@ $ rake notes:fixme
|
|
427
427
|
app/controllers/admin/users_controller.rb:
|
428
428
|
* [132] high priority for next deploy
|
429
429
|
|
430
|
-
app/
|
430
|
+
app/models/school.rb:
|
431
431
|
* [ 17]
|
432
432
|
```
|
433
433
|
|
@@ -436,7 +436,7 @@ You can also use custom annotations in your code and list them using `rake notes
|
|
436
436
|
```bash
|
437
437
|
$ rake notes:custom ANNOTATION=BUG
|
438
438
|
(in /home/foobar/commandsapp)
|
439
|
-
app/
|
439
|
+
app/models/post.rb:
|
440
440
|
* [ 23] Have to fix this one before pushing!
|
441
441
|
```
|
442
442
|
|
@@ -445,12 +445,12 @@ NOTE. When using specific annotations and custom annotations, the annotation nam
|
|
445
445
|
By default, `rake notes` will look in the `app`, `config`, `lib`, `bin` and `test` directories. If you would like to search other directories, you can provide them as a comma separated list in an environment variable `SOURCE_ANNOTATION_DIRECTORIES`.
|
446
446
|
|
447
447
|
```bash
|
448
|
-
$ export SOURCE_ANNOTATION_DIRECTORIES='
|
448
|
+
$ export SOURCE_ANNOTATION_DIRECTORIES='spec,vendor'
|
449
449
|
$ rake notes
|
450
450
|
(in /home/foobar/commandsapp)
|
451
|
-
app/
|
451
|
+
app/models/user.rb:
|
452
452
|
* [ 35] [FIXME] User should have a subscription at this point
|
453
|
-
|
453
|
+
spec/models/user_spec.rb:
|
454
454
|
* [122] [TODO] Verify the user that has a subscription works
|
455
455
|
```
|
456
456
|
|
@@ -268,7 +268,7 @@ config.middleware.delete "Rack::MethodOverride"
|
|
268
268
|
|
269
269
|
* `config.active_record.lock_optimistically` controls whether Active Record will use optimistic locking and is true by default.
|
270
270
|
|
271
|
-
*
|
271
|
+
* `config.active_record.cache_timestamp_format` controls the format of the timestamp value in the cache key. Default is `:number`.
|
272
272
|
|
273
273
|
The MySQL adapter adds one additional configuration option:
|
274
274
|
|
@@ -646,7 +646,7 @@ Below is a comprehensive list of all the initializers found in Rails in the orde
|
|
646
646
|
|
647
647
|
* `active_support.initialize_time_zone` Sets the default time zone for the application based on the `config.time_zone` setting, which defaults to "UTC".
|
648
648
|
|
649
|
-
* `active_support.initialize_beginning_of_week` Sets the default
|
649
|
+
* `active_support.initialize_beginning_of_week` Sets the default beginning of week for the application based on `config.beginning_of_week` setting, which defaults to `:monday`.
|
650
650
|
|
651
651
|
* `action_dispatch.configure` Configures the `ActionDispatch::Http::URL.tld_length` to be set to the value of `config.action_dispatch.tld_length`.
|
652
652
|
|
@@ -698,7 +698,7 @@ Below is a comprehensive list of all the initializers found in Rails in the orde
|
|
698
698
|
|
699
699
|
* `engines_blank_point` Provides a point-in-initialization to hook into if you wish to do anything before engines are loaded. After this point, all railtie and engine initializers are run.
|
700
700
|
|
701
|
-
* `add_generator_templates` Finds templates for generators at `lib/templates` for the application,
|
701
|
+
* `add_generator_templates` Finds templates for generators at `lib/templates` for the application, railties and engines and adds these to the `config.generators.templates` setting, which will make the templates available for all generators to reference.
|
702
702
|
|
703
703
|
* `ensure_autoload_once_paths_as_subset` Ensures that the `config.autoload_once_paths` only contains paths from `config.autoload_paths`. If it contains extra paths, then an exception will be raised.
|
704
704
|
|
@@ -24,12 +24,20 @@ NOTE: Bugs in the most recent released version of Ruby on Rails are likely to ge
|
|
24
24
|
|
25
25
|
### Creating a Bug Report
|
26
26
|
|
27
|
-
If you've found a problem in Ruby on Rails which is not a security risk, do a search in GitHub under [Issues](https://github.com/rails/rails/issues) in case it was already reported. If you find no issue addressing it you can [add a new one](https://github.com/rails/rails/issues/new). (See the next section for reporting security issues)
|
27
|
+
If you've found a problem in Ruby on Rails which is not a security risk, do a search in GitHub under [Issues](https://github.com/rails/rails/issues) in case it was already reported. If you find no issue addressing it you can [add a new one](https://github.com/rails/rails/issues/new). (See the next section for reporting security issues.)
|
28
28
|
|
29
29
|
At the minimum, your issue report needs a title and descriptive text. But that's only a minimum. You should include as much relevant information as possible. You need at least to post the code sample that has the issue. Even better is to include a unit test that shows how the expected behavior is not occurring. Your goal should be to make it easy for yourself — and others — to replicate the bug and figure out a fix.
|
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
|
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)
|
37
|
+
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
|
+
if the bug happens in the master branch.
|
40
|
+
|
33
41
|
### Special Treatment for Security Issues
|
34
42
|
|
35
43
|
WARNING: Please do not report security vulnerabilities with public GitHub issue reports. The [Rails security policy page](http://rubyonrails.org/security) details the procedure to follow for security issues.
|
@@ -53,6 +61,22 @@ The easiest and recommended way to get a development environment ready to hack i
|
|
53
61
|
|
54
62
|
In case you can't use the Rails development box, see section above, check [this other guide](development_dependencies_install.html).
|
55
63
|
|
64
|
+
|
65
|
+
Running an Application Against Your Local Branch
|
66
|
+
------------------------------------------------
|
67
|
+
|
68
|
+
The `--dev` flag of `rails new` generates an application that uses your local
|
69
|
+
branch:
|
70
|
+
|
71
|
+
```bash
|
72
|
+
$ cd rails
|
73
|
+
$ bundle exec rails new ~/my-test-app --dev
|
74
|
+
```
|
75
|
+
|
76
|
+
The application generated in `~/my-test-app` runs against your local branch
|
77
|
+
and in particular sees any modifications upon server reboot.
|
78
|
+
|
79
|
+
|
56
80
|
Testing Active Record
|
57
81
|
---------------------
|
58
82
|
|
@@ -190,7 +214,7 @@ $ cd rails
|
|
190
214
|
$ git checkout -b my_new_branch
|
191
215
|
```
|
192
216
|
|
193
|
-
It doesn’t matter much what name you use, because this branch will only exist on your local computer and your personal repository on
|
217
|
+
It doesn’t matter much what name you use, because this branch will only exist on your local computer and your personal repository on GitHub. It won't be part of the Rails Git repository.
|
194
218
|
|
195
219
|
### Write Your Code
|
196
220
|
|
@@ -201,6 +225,17 @@ Now get busy and add or edit code. You’re on your branch now, so you can write
|
|
201
225
|
* Include tests that fail without your code, and pass with it.
|
202
226
|
* Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution.
|
203
227
|
|
228
|
+
It is not customary in Rails to run the full test suite before pushing
|
229
|
+
changes. The railties test suite in particular takes a long time, and even
|
230
|
+
more if the source code is mounted in `/vagrant` as happens in the recommended
|
231
|
+
workflow with the [rails-dev-box](https://github.com/rails/rails-dev-box).
|
232
|
+
|
233
|
+
As a compromise, test what your code obviously affects, and if the change is
|
234
|
+
not in railties run the whole test suite of the affected component. If all is
|
235
|
+
green that's enough to propose your contribution. We have [Travis CI](https
|
236
|
+
://travis-ci.org/) as a safety net for catching unexpected breakages
|
237
|
+
elsewhere.
|
238
|
+
|
204
239
|
TIP: Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of Rails will generally not be accepted.
|
205
240
|
|
206
241
|
### Follow the Coding Conventions
|
@@ -225,7 +260,7 @@ The above are guidelines — please use your best judgment in using them.
|
|
225
260
|
|
226
261
|
The CHANGELOG is an important part of every release. It keeps the list of changes for every Rails version.
|
227
262
|
|
228
|
-
You should add an entry to the CHANGELOG of the framework that you modified if you're adding or removing a feature,
|
263
|
+
You should add an entry to the CHANGELOG of the framework that you modified if you're adding or removing a feature, committing a bug fix or adding deprecation notices. Refactorings and documentation changes generally should not go to the CHANGELOG.
|
229
264
|
|
230
265
|
A CHANGELOG entry should summarize what was changed and should end with author's name. You can use multiple lines if you need more space and you can attach code examples indented with 4 spaces. If a change is related to a specific issue, you should attach issue's number. Here is an example CHANGELOG entry:
|
231
266
|
|
@@ -250,8 +285,6 @@ Your name can be added directly after the last word if you don't provide any cod
|
|
250
285
|
|
251
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.
|
252
287
|
|
253
|
-
You might want also to check out the [RailsBridge BugMash](http://wiki.railsbridge.org/projects/railsbridge/wiki/BugMash) as a way to get involved in a group effort to improve Rails. This can help you get started and help you check your code when you're writing your first patches.
|
254
|
-
|
255
288
|
### Commit Your Changes
|
256
289
|
|
257
290
|
When you're happy with the code on your computer, you need to commit the changes to Git:
|
@@ -28,7 +28,7 @@ Ruby on Rails Guides: Credits
|
|
28
28
|
<h3 class="section">Rails Guides Authors</h3>
|
29
29
|
|
30
30
|
<%= author('Ryan Bigg', 'radar', 'radar.png') do %>
|
31
|
-
Ryan Bigg works as
|
31
|
+
Ryan Bigg works as the Community Manager at <a href="http://spreecommerce.com">Spree Commerce</a> and has been working with Rails since 2006. He's the author of <a href="https://leanpub.com/multi-tenancy-rails">Multi Tenancy With Rails</a> and co-author of <a href="http://manning.com/bigg2">Rails 4 in Action</a>. He's written many gems which can be seen on <a href="https://github.com/radar">his GitHub page</a> and he also tweets prolifically as <a href="http://twitter.com/ryanbigg">@ryanbigg</a>.
|
32
32
|
<% end %>
|
33
33
|
|
34
34
|
<%= author('Oscar Del Ben', 'oscardelben', 'oscardelben.jpg') do %>
|