rails 4.2.11 → 5.0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -10
  3. metadata +37 -245
  4. data/guides/CHANGELOG.md +0 -98
  5. data/guides/Rakefile +0 -92
  6. data/guides/assets/images/akshaysurve.jpg +0 -0
  7. data/guides/assets/images/belongs_to.png +0 -0
  8. data/guides/assets/images/book_icon.gif +0 -0
  9. data/guides/assets/images/bullet.gif +0 -0
  10. data/guides/assets/images/chapters_icon.gif +0 -0
  11. data/guides/assets/images/check_bullet.gif +0 -0
  12. data/guides/assets/images/credits_pic_blank.gif +0 -0
  13. data/guides/assets/images/csrf.png +0 -0
  14. data/guides/assets/images/edge_badge.png +0 -0
  15. data/guides/assets/images/favicon.ico +0 -0
  16. data/guides/assets/images/feature_tile.gif +0 -0
  17. data/guides/assets/images/footer_tile.gif +0 -0
  18. data/guides/assets/images/fxn.png +0 -0
  19. data/guides/assets/images/getting_started/article_with_comments.png +0 -0
  20. data/guides/assets/images/getting_started/challenge.png +0 -0
  21. data/guides/assets/images/getting_started/confirm_dialog.png +0 -0
  22. data/guides/assets/images/getting_started/forbidden_attributes_for_new_article.png +0 -0
  23. data/guides/assets/images/getting_started/form_with_errors.png +0 -0
  24. data/guides/assets/images/getting_started/index_action_with_edit_link.png +0 -0
  25. data/guides/assets/images/getting_started/new_article.png +0 -0
  26. data/guides/assets/images/getting_started/rails_welcome.png +0 -0
  27. data/guides/assets/images/getting_started/routing_error_no_controller.png +0 -0
  28. data/guides/assets/images/getting_started/routing_error_no_route_matches.png +0 -0
  29. data/guides/assets/images/getting_started/show_action_for_articles.png +0 -0
  30. data/guides/assets/images/getting_started/template_is_missing_articles_new.png +0 -0
  31. data/guides/assets/images/getting_started/unknown_action_create_for_articles.png +0 -0
  32. data/guides/assets/images/getting_started/unknown_action_new_for_articles.png +0 -0
  33. data/guides/assets/images/grey_bullet.gif +0 -0
  34. data/guides/assets/images/habtm.png +0 -0
  35. data/guides/assets/images/has_many.png +0 -0
  36. data/guides/assets/images/has_many_through.png +0 -0
  37. data/guides/assets/images/has_one.png +0 -0
  38. data/guides/assets/images/has_one_through.png +0 -0
  39. data/guides/assets/images/header_backdrop.png +0 -0
  40. data/guides/assets/images/header_tile.gif +0 -0
  41. data/guides/assets/images/i18n/demo_html_safe.png +0 -0
  42. data/guides/assets/images/i18n/demo_localized_pirate.png +0 -0
  43. data/guides/assets/images/i18n/demo_translated_en.png +0 -0
  44. data/guides/assets/images/i18n/demo_translated_pirate.png +0 -0
  45. data/guides/assets/images/i18n/demo_translation_missing.png +0 -0
  46. data/guides/assets/images/i18n/demo_untranslated.png +0 -0
  47. data/guides/assets/images/icons/README +0 -5
  48. data/guides/assets/images/icons/callouts/1.png +0 -0
  49. data/guides/assets/images/icons/callouts/10.png +0 -0
  50. data/guides/assets/images/icons/callouts/11.png +0 -0
  51. data/guides/assets/images/icons/callouts/12.png +0 -0
  52. data/guides/assets/images/icons/callouts/13.png +0 -0
  53. data/guides/assets/images/icons/callouts/14.png +0 -0
  54. data/guides/assets/images/icons/callouts/15.png +0 -0
  55. data/guides/assets/images/icons/callouts/2.png +0 -0
  56. data/guides/assets/images/icons/callouts/3.png +0 -0
  57. data/guides/assets/images/icons/callouts/4.png +0 -0
  58. data/guides/assets/images/icons/callouts/5.png +0 -0
  59. data/guides/assets/images/icons/callouts/6.png +0 -0
  60. data/guides/assets/images/icons/callouts/7.png +0 -0
  61. data/guides/assets/images/icons/callouts/8.png +0 -0
  62. data/guides/assets/images/icons/callouts/9.png +0 -0
  63. data/guides/assets/images/icons/caution.png +0 -0
  64. data/guides/assets/images/icons/example.png +0 -0
  65. data/guides/assets/images/icons/home.png +0 -0
  66. data/guides/assets/images/icons/important.png +0 -0
  67. data/guides/assets/images/icons/next.png +0 -0
  68. data/guides/assets/images/icons/note.png +0 -0
  69. data/guides/assets/images/icons/prev.png +0 -0
  70. data/guides/assets/images/icons/tip.png +0 -0
  71. data/guides/assets/images/icons/up.png +0 -0
  72. data/guides/assets/images/icons/warning.png +0 -0
  73. data/guides/assets/images/nav_arrow.gif +0 -0
  74. data/guides/assets/images/oscardelben.jpg +0 -0
  75. data/guides/assets/images/polymorphic.png +0 -0
  76. data/guides/assets/images/radar.png +0 -0
  77. data/guides/assets/images/rails4_features.png +0 -0
  78. data/guides/assets/images/rails_guides_kindle_cover.jpg +0 -0
  79. data/guides/assets/images/rails_guides_logo.gif +0 -0
  80. data/guides/assets/images/rails_logo_remix.gif +0 -0
  81. data/guides/assets/images/session_fixation.png +0 -0
  82. data/guides/assets/images/tab_grey.gif +0 -0
  83. data/guides/assets/images/tab_info.gif +0 -0
  84. data/guides/assets/images/tab_note.gif +0 -0
  85. data/guides/assets/images/tab_red.gif +0 -0
  86. data/guides/assets/images/tab_yellow.gif +0 -0
  87. data/guides/assets/images/tab_yellow.png +0 -0
  88. data/guides/assets/images/vijaydev.jpg +0 -0
  89. data/guides/assets/javascripts/guides.js +0 -59
  90. data/guides/assets/javascripts/jquery.min.js +0 -4
  91. data/guides/assets/javascripts/responsive-tables.js +0 -43
  92. data/guides/assets/javascripts/syntaxhighlighter/shBrushAS3.js +0 -59
  93. data/guides/assets/javascripts/syntaxhighlighter/shBrushAppleScript.js +0 -75
  94. data/guides/assets/javascripts/syntaxhighlighter/shBrushBash.js +0 -59
  95. data/guides/assets/javascripts/syntaxhighlighter/shBrushCSharp.js +0 -65
  96. data/guides/assets/javascripts/syntaxhighlighter/shBrushColdFusion.js +0 -100
  97. data/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js +0 -97
  98. data/guides/assets/javascripts/syntaxhighlighter/shBrushCss.js +0 -91
  99. data/guides/assets/javascripts/syntaxhighlighter/shBrushDelphi.js +0 -55
  100. data/guides/assets/javascripts/syntaxhighlighter/shBrushDiff.js +0 -41
  101. data/guides/assets/javascripts/syntaxhighlighter/shBrushErlang.js +0 -52
  102. data/guides/assets/javascripts/syntaxhighlighter/shBrushGroovy.js +0 -67
  103. data/guides/assets/javascripts/syntaxhighlighter/shBrushJScript.js +0 -52
  104. data/guides/assets/javascripts/syntaxhighlighter/shBrushJava.js +0 -57
  105. data/guides/assets/javascripts/syntaxhighlighter/shBrushJavaFX.js +0 -58
  106. data/guides/assets/javascripts/syntaxhighlighter/shBrushPerl.js +0 -72
  107. data/guides/assets/javascripts/syntaxhighlighter/shBrushPhp.js +0 -88
  108. data/guides/assets/javascripts/syntaxhighlighter/shBrushPlain.js +0 -33
  109. data/guides/assets/javascripts/syntaxhighlighter/shBrushPowerShell.js +0 -74
  110. data/guides/assets/javascripts/syntaxhighlighter/shBrushPython.js +0 -64
  111. data/guides/assets/javascripts/syntaxhighlighter/shBrushRuby.js +0 -55
  112. data/guides/assets/javascripts/syntaxhighlighter/shBrushSass.js +0 -94
  113. data/guides/assets/javascripts/syntaxhighlighter/shBrushScala.js +0 -51
  114. data/guides/assets/javascripts/syntaxhighlighter/shBrushSql.js +0 -66
  115. data/guides/assets/javascripts/syntaxhighlighter/shBrushVb.js +0 -56
  116. data/guides/assets/javascripts/syntaxhighlighter/shBrushXml.js +0 -69
  117. data/guides/assets/javascripts/syntaxhighlighter/shCore.js +0 -17
  118. data/guides/assets/stylesheets/fixes.css +0 -16
  119. data/guides/assets/stylesheets/kindle.css +0 -11
  120. data/guides/assets/stylesheets/main.css +0 -713
  121. data/guides/assets/stylesheets/print.css +0 -52
  122. data/guides/assets/stylesheets/reset.css +0 -43
  123. data/guides/assets/stylesheets/responsive-tables.css +0 -50
  124. data/guides/assets/stylesheets/style.css +0 -13
  125. data/guides/assets/stylesheets/syntaxhighlighter/shCore.css +0 -226
  126. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDefault.css +0 -328
  127. data/guides/assets/stylesheets/syntaxhighlighter/shCoreDjango.css +0 -331
  128. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEclipse.css +0 -339
  129. data/guides/assets/stylesheets/syntaxhighlighter/shCoreEmacs.css +0 -324
  130. data/guides/assets/stylesheets/syntaxhighlighter/shCoreFadeToGrey.css +0 -328
  131. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMDUltra.css +0 -324
  132. data/guides/assets/stylesheets/syntaxhighlighter/shCoreMidnight.css +0 -324
  133. data/guides/assets/stylesheets/syntaxhighlighter/shCoreRDark.css +0 -324
  134. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDefault.css +0 -117
  135. data/guides/assets/stylesheets/syntaxhighlighter/shThemeDjango.css +0 -120
  136. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEclipse.css +0 -128
  137. data/guides/assets/stylesheets/syntaxhighlighter/shThemeEmacs.css +0 -113
  138. data/guides/assets/stylesheets/syntaxhighlighter/shThemeFadeToGrey.css +0 -117
  139. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMDUltra.css +0 -113
  140. data/guides/assets/stylesheets/syntaxhighlighter/shThemeMidnight.css +0 -113
  141. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRDark.css +0 -113
  142. data/guides/assets/stylesheets/syntaxhighlighter/shThemeRailsGuides.css +0 -116
  143. data/guides/bug_report_templates/action_controller_gem.rb +0 -47
  144. data/guides/bug_report_templates/action_controller_master.rb +0 -54
  145. data/guides/bug_report_templates/active_record_gem.rb +0 -40
  146. data/guides/bug_report_templates/active_record_master.rb +0 -49
  147. data/guides/bug_report_templates/generic_gem.rb +0 -15
  148. data/guides/bug_report_templates/generic_master.rb +0 -26
  149. data/guides/rails_guides.rb +0 -63
  150. data/guides/rails_guides/generator.rb +0 -248
  151. data/guides/rails_guides/helpers.rb +0 -53
  152. data/guides/rails_guides/indexer.rb +0 -68
  153. data/guides/rails_guides/kindle.rb +0 -119
  154. data/guides/rails_guides/levenshtein.rb +0 -37
  155. data/guides/rails_guides/markdown.rb +0 -167
  156. data/guides/rails_guides/markdown/renderer.rb +0 -82
  157. data/guides/source/2_2_release_notes.md +0 -435
  158. data/guides/source/2_3_release_notes.md +0 -621
  159. data/guides/source/3_0_release_notes.md +0 -611
  160. data/guides/source/3_1_release_notes.md +0 -559
  161. data/guides/source/3_2_release_notes.md +0 -568
  162. data/guides/source/4_0_release_notes.md +0 -279
  163. data/guides/source/4_1_release_notes.md +0 -730
  164. data/guides/source/4_2_release_notes.md +0 -877
  165. data/guides/source/_license.html.erb +0 -2
  166. data/guides/source/_welcome.html.erb +0 -23
  167. data/guides/source/action_controller_overview.md +0 -1192
  168. data/guides/source/action_mailer_basics.md +0 -757
  169. data/guides/source/action_view_overview.md +0 -1561
  170. data/guides/source/active_job_basics.md +0 -339
  171. data/guides/source/active_model_basics.md +0 -554
  172. data/guides/source/active_record_basics.md +0 -374
  173. data/guides/source/active_record_callbacks.md +0 -413
  174. data/guides/source/active_record_migrations.md +0 -1018
  175. data/guides/source/active_record_postgresql.md +0 -433
  176. data/guides/source/active_record_querying.md +0 -1781
  177. data/guides/source/active_record_validations.md +0 -1179
  178. data/guides/source/active_support_core_extensions.md +0 -3856
  179. data/guides/source/active_support_instrumentation.md +0 -488
  180. data/guides/source/api_documentation_guidelines.md +0 -361
  181. data/guides/source/asset_pipeline.md +0 -1304
  182. data/guides/source/association_basics.md +0 -2245
  183. data/guides/source/autoloading_and_reloading_constants.md +0 -1311
  184. data/guides/source/caching_with_rails.md +0 -379
  185. data/guides/source/command_line.md +0 -625
  186. data/guides/source/configuring.md +0 -1070
  187. data/guides/source/contributing_to_ruby_on_rails.md +0 -628
  188. data/guides/source/credits.html.erb +0 -80
  189. data/guides/source/debugging_rails_applications.md +0 -861
  190. data/guides/source/development_dependencies_install.md +0 -289
  191. data/guides/source/documents.yaml +0 -205
  192. data/guides/source/engines.md +0 -1412
  193. data/guides/source/form_helpers.md +0 -1024
  194. data/guides/source/generators.md +0 -676
  195. data/guides/source/getting_started.md +0 -2086
  196. data/guides/source/i18n.md +0 -1087
  197. data/guides/source/index.html.erb +0 -28
  198. data/guides/source/initialization.md +0 -704
  199. data/guides/source/kindle/copyright.html.erb +0 -1
  200. data/guides/source/kindle/layout.html.erb +0 -27
  201. data/guides/source/kindle/rails_guides.opf.erb +0 -52
  202. data/guides/source/kindle/toc.html.erb +0 -24
  203. data/guides/source/kindle/toc.ncx.erb +0 -64
  204. data/guides/source/kindle/welcome.html.erb +0 -5
  205. data/guides/source/layout.html.erb +0 -140
  206. data/guides/source/layouts_and_rendering.md +0 -1226
  207. data/guides/source/maintenance_policy.md +0 -78
  208. data/guides/source/nested_model_forms.md +0 -228
  209. data/guides/source/plugins.md +0 -444
  210. data/guides/source/rails_application_templates.md +0 -266
  211. data/guides/source/rails_on_rack.md +0 -335
  212. data/guides/source/routing.md +0 -1155
  213. data/guides/source/ruby_on_rails_guides_guidelines.md +0 -127
  214. data/guides/source/security.md +0 -1024
  215. data/guides/source/testing.md +0 -1132
  216. data/guides/source/upgrading_ruby_on_rails.md +0 -1186
  217. data/guides/source/working_with_javascript_in_rails.md +0 -407
  218. data/guides/w3c_validator.rb +0 -97
@@ -1,628 +0,0 @@
1
- Contributing to Ruby on Rails
2
- =============================
3
-
4
- This guide covers ways in which _you_ can become a part of the ongoing development of Ruby on Rails.
5
-
6
- After reading this guide, you will know:
7
-
8
- * How to use GitHub to report issues.
9
- * How to clone master and run the test suite.
10
- * How to help resolve existing issues.
11
- * How to contribute to the Ruby on Rails documentation.
12
- * How to contribute to the Ruby on Rails code.
13
-
14
- Ruby on Rails is not "someone else's framework." Over the years, hundreds of people have contributed to Ruby on Rails ranging from a single character to massive architectural changes or significant documentation - all with the goal of making Ruby on Rails better for everyone. Even if you don't feel up to writing code or documentation yet, there are a variety of other ways that you can contribute, from reporting issues to testing patches.
15
-
16
- --------------------------------------------------------------------------------
17
-
18
- Reporting an Issue
19
- ------------------
20
-
21
- Ruby on Rails uses [GitHub Issue Tracking](https://github.com/rails/rails/issues) to track issues (primarily bugs and contributions of new code). If you've found a bug in Ruby on Rails, this is the place to start. You'll need to create a (free) GitHub account in order to submit an issue, to comment on them or to create pull requests.
22
-
23
- NOTE: Bugs in the most recent released version of Ruby on Rails are likely to get the most attention. Also, the Rails core team is always interested in feedback from those who can take the time to test _edge Rails_ (the code for the version of Rails that is currently under development). Later in this guide you'll find out how to get edge Rails for testing.
24
-
25
- ### Creating a Bug Report
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 has already been reported. If you do not find any issue addressing it you may proceed to [open a new one](https://github.com/rails/rails/issues/new). (See the next section for reporting security issues.)
28
-
29
- Your issue report should contain a title and a clear description of the issue at the bare minimum. You should include as much relevant information as possible and should at least post a code sample that demonstrates the issue. It would be even better if you could 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
-
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
-
33
- ### Create a Self-Contained gist for Active Record and Action Controller Issues
34
-
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)
38
- if the bug is found in a published gem, and
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)
41
- if the bug happens in the master branch.
42
-
43
- ### Special Treatment for Security Issues
44
-
45
- 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.
46
-
47
- ### What about Feature Requests?
48
-
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 wish list 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 misbehaving. 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.
71
-
72
-
73
- Helping to Resolve Existing Issues
74
- ----------------------------------
75
-
76
- As a next step beyond reporting issues, you can help the core team resolve existing issues. If you check the [Everyone's Issues](https://github.com/rails/rails/issues) list in GitHub Issues, you'll find lots of issues already requiring attention. What can you do for these? Quite a bit, actually:
77
-
78
- ### Verifying Bug Reports
79
-
80
- For starters, it helps just to verify bug reports. Can you reproduce the reported issue on your own computer? If so, you can add a comment to the issue saying that you're seeing the same thing.
81
-
82
- If something is very vague, can you help squash it down into something specific? Maybe you can provide additional information to help reproduce a bug, or help by eliminating needless steps that aren't required to demonstrate the problem.
83
-
84
- If you find a bug report without a test, it's very useful to contribute a failing test. This is also a great way to get started exploring the source code: looking at the existing test files will teach you how to write more tests. New tests are best contributed in the form of a patch, as explained later on in the "Contributing to the Rails Code" section.
85
-
86
- Anything you can do to make bug reports more succinct or easier to reproduce is a help to folks trying to write code to fix those bugs - whether you end up writing the code yourself or not.
87
-
88
- ### Testing Patches
89
-
90
- You can also help out by examining pull requests that have been submitted to Ruby on Rails via GitHub. To apply someone's changes you need first to create a dedicated branch:
91
-
92
- ```bash
93
- $ git checkout -b testing_branch
94
- ```
95
-
96
- Then you can use their remote branch to update your codebase. For example, let's say the GitHub user JohnSmith has forked and pushed to a topic branch "orange" located at https://github.com/JohnSmith/rails.
97
-
98
- ```bash
99
- $ git remote add JohnSmith git://github.com/JohnSmith/rails.git
100
- $ git pull JohnSmith orange
101
- ```
102
-
103
- After applying their branch, test it out! Here are some things to think about:
104
-
105
- * Does the change actually work?
106
- * Are you happy with the tests? Can you follow what they're testing? Are there any tests missing?
107
- * Does it have the proper documentation coverage? Should documentation elsewhere be updated?
108
- * Do you like the implementation? Can you think of a nicer or faster way to implement a part of their change?
109
-
110
- Once you're happy that the pull request contains a good change, comment on the GitHub issue indicating your approval. Your comment should indicate that you like the change and what you like about it. Something like:
111
-
112
- >I like the way you've restructured that code in generate_finder_sql - much nicer. The tests look good too.
113
-
114
- If your comment simply says "+1", then odds are that other reviewers aren't going to take it too seriously. Show that you took the time to review the pull request.
115
-
116
- Contributing to the Rails Documentation
117
- ---------------------------------------
118
-
119
- Ruby on Rails has two main sets of documentation: the guides, which help you
120
- learn about Ruby on Rails, and the API, which serves as a reference.
121
-
122
- 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.
123
-
124
- You can either open a pull request to [Rails](http://github.com/rails/rails) or
125
- ask the [Rails core team](http://rubyonrails.org/core) for commit access on
126
- docrails if you contribute regularly.
127
- Please do not open pull requests in docrails, if you'd like to get feedback on your
128
- change, ask for it in [Rails](http://github.com/rails/rails) instead.
129
-
130
- Docrails is merged with master regularly, so you are effectively editing the Ruby on Rails documentation.
131
-
132
- 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.
133
-
134
- When working with documentation, please take into account the [API Documentation Guidelines](api_documentation_guidelines.html) and the [Ruby on Rails Guides Guidelines](ruby_on_rails_guides_guidelines.html).
135
-
136
- NOTE: As explained earlier, ordinary code patches should have proper documentation coverage. Docrails is only used for isolated documentation improvements.
137
-
138
- NOTE: To help our CI servers you should add [ci skip] to your documentation commit message to skip build on that commit. Please remember to use it for commits containing only documentation changes.
139
-
140
- WARNING: Docrails has a very strict policy: no code can be touched whatsoever, no matter how trivial or small the change. Only RDoc and guides can be edited via docrails. Also, CHANGELOGs should never be edited in docrails.
141
-
142
- Contributing to the Rails Code
143
- ------------------------------
144
-
145
- ### Setting Up a Development Environment
146
-
147
- To move on from submitting bugs to helping resolve existing issues or contributing your own code to Ruby on Rails, you _must_ be able to run its test suite. In this section of the guide you'll learn how to setup the tests on your own computer.
148
-
149
- #### The Easy Way
150
-
151
- The easiest and recommended way to get a development environment ready to hack is to use the [Rails development box](https://github.com/rails/rails-dev-box).
152
-
153
- #### The Hard Way
154
-
155
- In case you can't use the Rails development box, see [this other guide](development_dependencies_install.html).
156
-
157
- ### Clone the Rails Repository
158
-
159
- To be able to contribute code, you need to clone the Rails repository:
160
-
161
- ```bash
162
- $ git clone git://github.com/rails/rails.git
163
- ```
164
-
165
- and create a dedicated branch:
166
-
167
- ```bash
168
- $ cd rails
169
- $ git checkout -b my_new_branch
170
- ```
171
-
172
- 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.
173
-
174
- ### Running an Application Against Your Local Branch
175
-
176
- In case you need a dummy Rails app to test changes, the `--dev` flag of `rails new` generates an application that uses your local branch:
177
-
178
- ```bash
179
- $ cd rails
180
- $ bundle exec rails new ~/my-test-app --dev
181
- ```
182
-
183
- The application generated in `~/my-test-app` runs against your local branch
184
- and in particular sees any modifications upon server reboot.
185
-
186
- ### Write Your Code
187
-
188
- Now get busy and add/edit code. You're on your branch now, so you can write whatever you want (make sure you're on the right branch with `git branch -a`). But if you're planning to submit your change back for inclusion in Rails, keep a few things in mind:
189
-
190
- * Get the code right.
191
- * Use Rails idioms and helpers.
192
- * Include tests that fail without your code, and pass with it.
193
- * Update the (surrounding) documentation, examples elsewhere, and the guides: whatever is affected by your contribution.
194
-
195
-
196
- 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 (read more about [our rationales behind this decision](https://github.com/rails/rails/pull/13771#issuecomment-32746700)).
197
-
198
- #### Follow the Coding Conventions
199
-
200
- Rails follows a simple set of coding style conventions:
201
-
202
- * Two spaces, no tabs (for indentation).
203
- * No trailing whitespace. Blank lines should not have any spaces.
204
- * Indent after private/protected.
205
- * Use Ruby >= 1.9 syntax for hashes. Prefer `{ a: :b }` over `{ :a => :b }`.
206
- * Prefer `&&`/`||` over `and`/`or`.
207
- * Prefer class << self over self.method for class methods.
208
- * Use `MyClass.my_method(my_arg)` not `my_method( my_arg )` or `my_method my_arg`.
209
- * Use `a = b` and not `a=b`.
210
- * Use assert_not methods instead of refute.
211
- * Prefer `method { do_stuff }` instead of `method{do_stuff}` for single-line blocks.
212
- * Follow the conventions in the source you see used already.
213
-
214
- The above are guidelines - please use your best judgment in using them.
215
-
216
- ### Benchmark Your Code
217
-
218
- If your change has an impact on the performance of Rails, please use the
219
- [benchmark-ips](https://github.com/evanphx/benchmark-ips) gem to provide
220
- benchmark results for comparison.
221
-
222
- Here's an example of using benchmark-ips:
223
-
224
- ```ruby
225
- require 'benchmark/ips'
226
-
227
- Benchmark.ips do |x|
228
- x.report('addition') { 1 + 2 }
229
- x.report('addition with send') { 1.send(:+, 2) }
230
- end
231
- ```
232
-
233
- This will generate a report with the following information:
234
-
235
- ```
236
- Calculating -------------------------------------
237
- addition 69114 i/100ms
238
- addition with send 64062 i/100ms
239
- -------------------------------------------------
240
- addition 5307644.4 (±3.5%) i/s - 26539776 in 5.007219s
241
- addition with send 3702897.9 (±3.5%) i/s - 18513918 in 5.006723s
242
- ```
243
-
244
- Please see the benchmark/ips [README](https://github.com/evanphx/benchmark-ips/blob/master/README.md) for more information.
245
-
246
- ### Running Tests
247
-
248
- It is not customary in Rails to run the full test suite before pushing
249
- changes. The railties test suite in particular takes a long time, and even
250
- more if the source code is mounted in `/vagrant` as happens in the recommended
251
- workflow with the [rails-dev-box](https://github.com/rails/rails-dev-box).
252
-
253
- As a compromise, test what your code obviously affects, and if the change is
254
- not in railties, run the whole test suite of the affected component. If all
255
- tests are passing, that's enough to propose your contribution. We have
256
- [Travis CI](https://travis-ci.org/rails/rails) as a safety net for catching
257
- unexpected breakages elsewhere.
258
-
259
- #### Entire Rails:
260
-
261
- To run all the tests, do:
262
-
263
- ```bash
264
- $ cd rails
265
- $ bundle exec rake test
266
- ```
267
-
268
- #### For a Particular Component
269
-
270
- You can run tests only for a particular component (e.g. Action Pack). For example,
271
- to run Action Mailer tests:
272
-
273
- ```bash
274
- $ cd actionmailer
275
- $ bundle exec rake test
276
- ```
277
-
278
- #### Running a Single Test
279
-
280
- You can run a single test through ruby. For instance:
281
-
282
- ```bash
283
- $ cd actionmailer
284
- $ bundle exec ruby -w -Itest test/mail_layout_test.rb -n test_explicit_class_layout
285
- ```
286
-
287
- The `-n` option allows you to run a single method instead of the whole
288
- file.
289
-
290
- ##### Testing Active Record
291
-
292
- This is how you run the Active Record test suite only for SQLite3:
293
-
294
- ```bash
295
- $ cd activerecord
296
- $ bundle exec rake test:sqlite3
297
- ```
298
-
299
- You can now run the tests as you did for `sqlite3`. The tasks are respectively
300
-
301
- ```bash
302
- test:mysql
303
- test:mysql2
304
- test:postgresql
305
- ```
306
-
307
- Finally,
308
-
309
- ```bash
310
- $ bundle exec rake test
311
- ```
312
-
313
- will now run the four of them in turn.
314
-
315
- You can also run any single test separately:
316
-
317
- ```bash
318
- $ ARCONN=sqlite3 ruby -Itest test/cases/associations/has_many_associations_test.rb
319
- ```
320
-
321
- To run a single test against all adapters, use:
322
-
323
- ```bash
324
- $ bundle exec rake TEST=test/cases/associations/has_many_associations_test.rb
325
- ```
326
-
327
- You can invoke `test_jdbcmysql`, `test_jdbcsqlite3` or `test_jdbcpostgresql` also. See the file `activerecord/RUNNING_UNIT_TESTS.rdoc` for information on running more targeted database tests, or the file `ci/travis.rb` for the test suite run by the continuous integration server.
328
-
329
- ### Warnings
330
-
331
- The test suite runs with warnings enabled. Ideally, Ruby on Rails should issue no warnings, but there may be a few, as well as some from third-party libraries. Please ignore (or fix!) them, if any, and submit patches that do not issue new warnings.
332
-
333
- If you are sure about what you are doing and would like to have a more clear output, there's a way to override the flag:
334
-
335
- ```bash
336
- $ RUBYOPT=-W0 bundle exec rake test
337
- ```
338
-
339
- ### Updating the CHANGELOG
340
-
341
- The CHANGELOG is an important part of every release. It keeps the list of changes for every Rails version.
342
-
343
- 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.
344
-
345
- A CHANGELOG entry should summarize what was changed and should end with author's name and it should go on top of a CHANGELOG. 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 the issue's number. Here is an example CHANGELOG entry:
346
-
347
- ```
348
- * Summary of a change that briefly describes what was changed. You can use multiple
349
- lines and wrap them at around 80 characters. Code examples are ok, too, if needed:
350
-
351
- class Foo
352
- def bar
353
- puts 'baz'
354
- end
355
- end
356
-
357
- You can continue after the code example and you can attach issue number. GH#1234
358
-
359
- *Your Name*
360
- ```
361
-
362
- Your name can be added directly after the last word if you don't provide any code examples or don't need multiple paragraphs. Otherwise, it's best to make as a new paragraph.
363
-
364
- ### Updating the Gemfile.lock
365
-
366
- Some changes requires the dependencies to be upgraded. In these cases make sure you run `bundle update` to get the right version of the dependency and commit the `Gemfile.lock` file within your changes.
367
-
368
- ### Sanity Check
369
-
370
- You should not be the only person who looks at the code before you submit it.
371
- If you know someone else who uses Rails, try asking them if they'll check out
372
- your work. If you don't know anyone else using Rails, try hopping into the IRC
373
- room or posting about your idea to the rails-core mailing list. Doing this in
374
- private before you push a patch out publicly is the "smoke test" for a patch:
375
- if you can't convince one other developer of the beauty of your code, you’re
376
- unlikely to convince the core team either.
377
-
378
- ### Commit Your Changes
379
-
380
- When you're happy with the code on your computer, you need to commit the changes to Git:
381
-
382
- ```bash
383
- $ git commit -a
384
- ```
385
-
386
- At this point, your editor should be fired up and you can write a message for this commit. Well formatted and descriptive commit messages are extremely helpful for the others, especially when figuring out why given change was made, so please take the time to write it.
387
-
388
- Good commit message should be formatted according to the following example:
389
-
390
- ```
391
- Short summary (ideally 50 characters or less)
392
-
393
- More detailed description, if necessary. It should be wrapped to 72
394
- characters. Try to be as descriptive as you can, even if you think that
395
- the commit content is obvious, it may not be obvious to others. You
396
- should add such description also if it's already present in bug tracker,
397
- it should not be necessary to visit a webpage to check the history.
398
-
399
- Description can have multiple paragraphs and you can use code examples
400
- inside, just indent it with 4 spaces:
401
-
402
- class ArticlesController
403
- def index
404
- render json: Article.limit(10)
405
- end
406
- end
407
-
408
- You can also add bullet points:
409
-
410
- - you can use dashes or asterisks
411
-
412
- - also, try to indent next line of a point for readability, if it's too
413
- long to fit in 72 characters
414
- ```
415
-
416
- TIP. Please squash your commits into a single commit when appropriate. This simplifies future cherry picks, and also keeps the git log clean.
417
-
418
- ### Update Your Branch
419
-
420
- It's pretty likely that other changes to master have happened while you were working. Go get them:
421
-
422
- ```bash
423
- $ git checkout master
424
- $ git pull --rebase
425
- ```
426
-
427
- Now reapply your patch on top of the latest changes:
428
-
429
- ```bash
430
- $ git checkout my_new_branch
431
- $ git rebase master
432
- ```
433
-
434
- No conflicts? Tests still pass? Change still seems reasonable to you? Then move on.
435
-
436
- ### Fork
437
-
438
- Navigate to the Rails [GitHub repository](https://github.com/rails/rails) and press "Fork" in the upper right hand corner.
439
-
440
- Add the new remote to your local repository on your local machine:
441
-
442
- ```bash
443
- $ git remote add mine git@github.com:<your user name>/rails.git
444
- ```
445
-
446
- Push to your remote:
447
-
448
- ```bash
449
- $ git push mine my_new_branch
450
- ```
451
-
452
- You might have cloned your forked repository into your machine and might want to add the original Rails repository as a remote instead, if that's the case here's what you have to do.
453
-
454
- In the directory you cloned your fork:
455
-
456
- ```bash
457
- $ git remote add rails git://github.com/rails/rails.git
458
- ```
459
-
460
- Download new commits and branches from the official repository:
461
-
462
- ```bash
463
- $ git fetch rails
464
- ```
465
-
466
- Merge the new content:
467
-
468
- ```bash
469
- $ git checkout master
470
- $ git rebase rails/master
471
- ```
472
-
473
- Update your fork:
474
-
475
- ```bash
476
- $ git push origin master
477
- ```
478
-
479
- If you want to update another branch:
480
-
481
- ```bash
482
- $ git checkout branch_name
483
- $ git rebase rails/branch_name
484
- $ git push origin branch_name
485
- ```
486
-
487
-
488
- ### Issue a Pull Request
489
-
490
- Navigate to the Rails repository you just pushed to (e.g.
491
- https://github.com/your-user-name/rails) and click on "Pull Requests" seen in
492
- the right panel. On the next page, press "New pull request" in the upper right
493
- hand corner.
494
-
495
- Click on "Edit", if you need to change the branches being compared (it compares
496
- "master" by default) and press "Click to create a pull request for this
497
- comparison".
498
-
499
- Ensure the changesets you introduced are included. Fill in some details about
500
- your potential patch including a meaningful title. When finished, press "Send
501
- pull request". The Rails core team will be notified about your submission.
502
-
503
- ### Get some Feedback
504
-
505
- Most pull requests will go through a few iterations before they get merged.
506
- Different contributors will sometimes have different opinions, and often
507
- patches will need revised before they can get merged.
508
-
509
- Some contributors to Rails have email notifications from GitHub turned on, but
510
- others do not. Furthermore, (almost) everyone who works on Rails is a
511
- volunteer, and so it may take a few days for you to get your first feedback on
512
- a pull request. Don't despair! Sometimes it's quick, sometimes it's slow. Such
513
- is the open source life.
514
-
515
- If it's been over a week, and you haven't heard anything, you might want to try
516
- and nudge things along. You can use the [rubyonrails-core mailing
517
- list](http://groups.google.com/group/rubyonrails-core/) for this. You can also
518
- leave another comment on the pull request.
519
-
520
- While you're waiting for feedback on your pull request, open up a few other
521
- pull requests and give someone else some! I'm sure they'll appreciate it in
522
- the same way that you appreciate feedback on your patches.
523
-
524
- ### Iterate as Necessary
525
-
526
- It's entirely possible that the feedback you get will suggest changes. Don't get discouraged: the whole point of contributing to an active open source project is to tap into the knowledge of the community. If people are encouraging you to tweak your code, then it's worth making the tweaks and resubmitting. If the feedback is that your code doesn't belong in the core, you might still think about releasing it as a gem.
527
-
528
- #### Squashing commits
529
-
530
- One of the things that we may ask you to do is to "squash your commits", which
531
- will combine all of your commits into a single commit. We prefer pull requests
532
- that are a single commit. This makes it easier to backport changes to stable
533
- branches, squashing makes it easier to revert bad commits, and the git history
534
- can be a bit easier to follow. Rails is a large project, and a bunch of
535
- extraneous commits can add a lot of noise.
536
-
537
- In order to do this, you'll need to have a git remote that points at the main
538
- Rails repository. This is useful anyway, but just in case you don't have it set
539
- up, make sure that you do this first:
540
-
541
- ```bash
542
- $ git remote add upstream https://github.com/rails/rails.git
543
- ```
544
-
545
- You can call this remote whatever you'd like, but if you don't use `upstream`,
546
- then change the name to your own in the instructions below.
547
-
548
- Given that your remote branch is called `my_pull_request`, then you can do the
549
- following:
550
-
551
- ```bash
552
- $ git fetch upstream
553
- $ git checkout my_pull_request
554
- $ git rebase upstream/master
555
- $ git rebase -i
556
-
557
- < Choose 'squash' for all of your commits except the first one. >
558
- < Edit the commit message to make sense, and describe all your changes. >
559
-
560
- $ git push origin my_pull_request -f
561
- ```
562
-
563
- You should be able to refresh the pull request on GitHub and see that it has
564
- been updated.
565
-
566
- #### Updating pull request
567
-
568
- Sometimes you will be asked to make some changes to the code you have
569
- already committed. This can include amending existing commits. In this
570
- case Git will not allow you to push the changes as the pushed branch
571
- and local branch do not match. Instead of opening a new pull request,
572
- you can force push to your branch on GitHub as described earlier in
573
- squashing commits section:
574
-
575
- ```bash
576
- $ git push origin my_pull_request -f
577
- ```
578
-
579
- This will update the branch and pull request on GitHub with your new code. Do
580
- note that using force push may result in commits being lost on the remote branch; use it with care.
581
-
582
-
583
- ### Older Versions of Ruby on Rails
584
-
585
- If you want to add a fix to older versions of Ruby on Rails, you'll need to set up and switch to your own local tracking branch. Here is an example to switch to the 4-0-stable branch:
586
-
587
- ```bash
588
- $ git branch --track 4-0-stable origin/4-0-stable
589
- $ git checkout 4-0-stable
590
- ```
591
-
592
- TIP: You may want to [put your Git branch name in your shell prompt](http://qugstart.com/blog/git-and-svn/add-colored-git-branch-name-to-your-shell-prompt/) to make it easier to remember which version of the code you're working with.
593
-
594
- #### Backporting
595
-
596
- Changes that are merged into master are intended for the next major release of Rails. Sometimes, it might be beneficial for your changes to propagate back to the maintenance releases for older stable branches. Generally, security fixes and bug fixes are good candidates for a backport, while new features and patches that introduce a change in behavior will not be accepted. When in doubt, it is best to consult a Rails team member before backporting your changes to avoid wasted effort.
597
-
598
- For simple fixes, the easiest way to backport your changes is to [extract a diff from your changes in master and apply them to the target branch](http://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git).
599
-
600
- First make sure your changes are the only difference between your current branch and master:
601
-
602
- ```bash
603
- $ git log master..HEAD
604
- ```
605
-
606
- Then extract the diff:
607
-
608
- ```bash
609
- $ git format-patch master --stdout > ~/my_changes.patch
610
- ```
611
-
612
- Switch over to the target branch and apply your changes:
613
-
614
- ```bash
615
- $ git checkout -b my_backport_branch 3-2-stable
616
- $ git apply ~/my_changes.patch
617
- ```
618
-
619
- This works well for simple changes. However, if your changes are complicated or if the code in master has deviated significantly from your target branch, it might require more work on your part. The difficulty of a backport varies greatly from case to case, and sometimes it is simply not worth the effort.
620
-
621
- Once you have resolved all conflicts and made sure all the tests are passing, push your changes and open a separate pull request for your backport. It is also worth noting that older branches might have a different set of build targets than master. When possible, it is best to first test your backport locally against the Ruby versions listed in `.travis.yml` before submitting your pull request.
622
-
623
- And then... think about your next contribution!
624
-
625
- Rails Contributors
626
- ------------------
627
-
628
- All contributions, either via master or docrails, get credit in [Rails Contributors](http://contributors.rubyonrails.org).