rails 4.2.0 → 4.2.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +5 -5
  2. data/guides/CHANGELOG.md +82 -0
  3. data/guides/Rakefile +16 -3
  4. data/guides/assets/images/getting_started/article_with_comments.png +0 -0
  5. data/guides/bug_report_templates/action_controller_gem.rb +1 -1
  6. data/guides/bug_report_templates/active_record_gem.rb +1 -1
  7. data/guides/bug_report_templates/generic_gem.rb +15 -0
  8. data/guides/bug_report_templates/generic_master.rb +26 -0
  9. data/guides/rails_guides/levenshtein.rb +0 -2
  10. data/guides/source/3_1_release_notes.md +1 -1
  11. data/guides/source/4_2_release_notes.md +27 -0
  12. data/guides/source/_welcome.html.erb +5 -1
  13. data/guides/source/action_controller_overview.md +2 -59
  14. data/guides/source/action_mailer_basics.md +8 -3
  15. data/guides/source/action_view_overview.md +2 -61
  16. data/guides/source/active_job_basics.md +27 -6
  17. data/guides/source/active_record_basics.md +6 -6
  18. data/guides/source/active_record_querying.md +1 -3
  19. data/guides/source/active_record_validations.md +3 -2
  20. data/guides/source/active_support_core_extensions.md +2 -50
  21. data/guides/source/active_support_instrumentation.md +0 -11
  22. data/guides/source/api_documentation_guidelines.md +1 -1
  23. data/guides/source/asset_pipeline.md +7 -63
  24. data/guides/source/association_basics.md +16 -7
  25. data/guides/source/{constant_autoloading_and_reloading.md → autoloading_and_reloading_constants.md} +42 -28
  26. data/guides/source/configuring.md +30 -5
  27. data/guides/source/contributing_to_ruby_on_rails.md +7 -3
  28. data/guides/source/documents.yaml +3 -3
  29. data/guides/source/engines.md +10 -10
  30. data/guides/source/getting_started.md +33 -32
  31. data/guides/source/i18n.md +3 -2
  32. data/guides/source/initialization.md +1 -1
  33. data/guides/source/layout.html.erb +4 -7
  34. data/guides/source/layouts_and_rendering.md +8 -9
  35. data/guides/source/rails_on_rack.md +0 -1
  36. data/guides/source/routing.md +15 -1
  37. data/guides/source/security.md +1 -1
  38. data/guides/source/testing.md +12 -3
  39. data/guides/source/upgrading_ruby_on_rails.md +35 -3
  40. data/guides/source/working_with_javascript_in_rails.md +1 -1
  41. metadata +22 -21
@@ -33,7 +33,7 @@ In general, the work of configuring Rails means configuring the components of Ra
33
33
  For example, the `config/application.rb` file includes this setting:
34
34
 
35
35
  ```ruby
36
- config.autoload_paths += %W(#{config.root}/extras)
36
+ config.time_zone = 'Central Time (US & Canada)'
37
37
  ```
38
38
 
39
39
  This is a setting for Rails itself. If you want to pass settings to individual Rails components, you can do so via the same `config` object in `config/application.rb`:
@@ -139,8 +139,6 @@ pipeline is enabled. It is set to true by default.
139
139
 
140
140
  * `config.assets.raise_runtime_errors` Set this flag to `true` to enable additional runtime error checking. Recommended in `config/environments/development.rb` to minimize unexpected behavior when deploying to `production`.
141
141
 
142
- * `config.assets.compress` a flag that enables the compression of compiled assets. It is explicitly set to true in `config/environments/production.rb`.
143
-
144
142
  * `config.assets.css_compressor` defines the CSS compressor to use. It is set by default by `sass-rails`. The unique alternative value at the moment is `:yui`, which uses the `yui-compressor` gem.
145
143
 
146
144
  * `config.assets.js_compressor` defines the JavaScript compressor to use. Possible values are `:closure`, `:uglifier` and `:yui` which require the use of the `closure-compiler`, `uglifier` or `yui-compressor` gems respectively.
@@ -197,7 +195,7 @@ The full set of methods that can be used in this block are as follows:
197
195
  Every Rails application comes with a standard set of middleware which it uses in this order in the development environment:
198
196
 
199
197
  * `ActionDispatch::SSL` forces every request to be under HTTPS protocol. Will be available if `config.force_ssl` is set to `true`. Options passed to this can be configured by using `config.ssl_options`.
200
- * `ActionDispatch::Static` is used to serve static assets. Disabled if `config.serve_static_assets` is `false`.
198
+ * `ActionDispatch::Static` is used to serve static assets. Disabled if `config.serve_static_files` is `false`.
201
199
  * `Rack::Lock` wraps the app in mutex so it can only be called by a single thread at a time. Only enabled when `config.cache_classes` is `false`.
202
200
  * `ActiveSupport::Cache::Strategy::LocalCache` serves as a basic memory backed cache. This cache is not thread safe and is intended only for serving as a temporary memory cache for a single thread.
203
201
  * `Rack::Runtime` sets an `X-Runtime` header, containing the time (in seconds) taken to execute the request.
@@ -1027,7 +1025,7 @@ NOTE. If you are running in a multi-threaded environment, there could be a chanc
1027
1025
  Custom configuration
1028
1026
  --------------------
1029
1027
 
1030
- You can configure your own code through the Rails configuration object with custom configuration. It works like this:
1028
+ You can configure your own code through the Rails configuration object with custom configuration under the `config.x` property. It works like this:
1031
1029
 
1032
1030
  ```ruby
1033
1031
  config.x.payment_processing.schedule = :daily
@@ -1043,3 +1041,30 @@ These configuration points are then available through the configuration object:
1043
1041
  Rails.configuration.x.super_debugger # => true
1044
1042
  Rails.configuration.x.super_debugger.not_set # => nil
1045
1043
  ```
1044
+
1045
+ You can also use Rails::Application.config_for to load whole configuration files:
1046
+
1047
+ ```ruby
1048
+ # config/payment.yml:
1049
+ production:
1050
+ environment: production
1051
+ merchant_id: production_merchant_id
1052
+ public_key: production_public_key
1053
+ private_key: production_private_key
1054
+ development:
1055
+ environment: sandbox
1056
+ merchant_id: development_merchant_id
1057
+ public_key: development_public_key
1058
+ private_key: development_private_key
1059
+
1060
+ # config/application.rb
1061
+ module MyApp
1062
+ class Application < Rails::Application
1063
+ config.x.payment = config_for(:payment)
1064
+ end
1065
+ end
1066
+ ```
1067
+
1068
+ ```ruby
1069
+ Rails.configuration.x.payment['merchant_id'] # => production_merchant_id or development_merchant_id
1070
+ ```
@@ -119,11 +119,11 @@ Contributing to the Rails Documentation
119
119
  Ruby on Rails has two main sets of documentation: the guides, which help you
120
120
  learn about Ruby on Rails, and the API, which serves as a reference.
121
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. To get involved in the translation of Rails guides, please see [Translating Rails Guides](https://wiki.github.com/rails/docrails/translating-rails-guides).
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
123
 
124
124
  You can either open a pull request to [Rails](http://github.com/rails/rails) or
125
125
  ask the [Rails core team](http://rubyonrails.org/core) for commit access on
126
- [docrails](http://github.com/rails/docrails) if you contribute regularly.
126
+ docrails if you contribute regularly.
127
127
  Please do not open pull requests in docrails, if you'd like to get feedback on your
128
128
  change, ask for it in [Rails](http://github.com/rails/rails) instead.
129
129
 
@@ -281,7 +281,7 @@ You can run a single test through ruby. For instance:
281
281
 
282
282
  ```bash
283
283
  $ cd actionmailer
284
- $ ruby -w -Itest test/mail_layout_test.rb -n test_explicit_class_layout
284
+ $ bundle exec ruby -w -Itest test/mail_layout_test.rb -n test_explicit_class_layout
285
285
  ```
286
286
 
287
287
  The `-n` option allows you to run a single method instead of the whole
@@ -361,6 +361,10 @@ A CHANGELOG entry should summarize what was changed and should end with author's
361
361
 
362
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
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
+
364
368
  ### Sanity Check
365
369
 
366
370
  You should not be the only person who looks at the code before you submit it.
@@ -123,9 +123,9 @@
123
123
  url: initialization.html
124
124
  description: This guide explains the internals of the Rails initialization process as of Rails 4
125
125
  -
126
- name: Constant Autoloading and Reloading
127
- url: constant_autoloading_and_reloading.html
128
- description: This guide documents how constant autoloading and reloading work.
126
+ name: Autoloading and Reloading Constants
127
+ url: autoloading_and_reloading_constants.html
128
+ description: This guide documents how autoloading and reloading constants work.
129
129
  -
130
130
  name: Extending Rails
131
131
  documents:
@@ -589,7 +589,7 @@ the comments, however, is not quite right yet. If you were to create a comment
589
589
  right now, you would see this error:
590
590
 
591
591
  ```
592
- Missing partial blorgh/comments/comment with {:handlers=>[:erb, :builder],
592
+ Missing partial blorgh/comments/_comment with {:handlers=>[:erb, :builder],
593
593
  :formats=>[:html], :locale=>[:en, :en]}. Searched in: *
594
594
  "/Users/ryan/Sites/side_projects/blorgh/test/dummy/app/views" *
595
595
  "/Users/ryan/Sites/side_projects/blorgh/app/views"
@@ -598,7 +598,7 @@ Missing partial blorgh/comments/comment with {:handlers=>[:erb, :builder],
598
598
  The engine is unable to find the partial required for rendering the comments.
599
599
  Rails looks first in the application's (`test/dummy`) `app/views` directory and
600
600
  then in the engine's `app/views` directory. When it can't find it, it will throw
601
- this error. The engine knows to look for `blorgh/comments/comment` because the
601
+ this error. The engine knows to look for `blorgh/comments/_comment` because the
602
602
  model object it is receiving is from the `Blorgh::Comment` class.
603
603
 
604
604
  This partial will be responsible for rendering just the comment text, for now.
@@ -696,8 +696,8 @@ haven't been copied over already. The first run for this command will output
696
696
  something such as this:
697
697
 
698
698
  ```bash
699
- Copied migration [timestamp_1]_create_blorgh_articles.rb from blorgh
700
- Copied migration [timestamp_2]_create_blorgh_comments.rb from blorgh
699
+ Copied migration [timestamp_1]_create_blorgh_articles.blorgh.rb from blorgh
700
+ Copied migration [timestamp_2]_create_blorgh_comments.blorgh.rb from blorgh
701
701
  ```
702
702
 
703
703
  The first timestamp (`[timestamp_1]`) will be the current time, and the second
@@ -829,11 +829,9 @@ Notice that only _one_ migration was copied over here. This is because the first
829
829
  two migrations were copied over the first time this command was run.
830
830
 
831
831
  ```
832
- NOTE Migration [timestamp]_create_blorgh_articles.rb from blorgh has been
833
- skipped. Migration with the same name already exists. NOTE Migration
834
- [timestamp]_create_blorgh_comments.rb from blorgh has been skipped. Migration
835
- with the same name already exists. Copied migration
836
- [timestamp]_add_author_id_to_blorgh_articles.rb from blorgh
832
+ NOTE Migration [timestamp]_create_blorgh_articles.blorgh.rb from blorgh has been skipped. Migration with the same name already exists.
833
+ NOTE Migration [timestamp]_create_blorgh_comments.blorgh.rb from blorgh has been skipped. Migration with the same name already exists.
834
+ Copied migration [timestamp]_add_author_id_to_blorgh_articles.blorgh.rb from blorgh
837
835
  ```
838
836
 
839
837
  Run the migration using:
@@ -888,7 +886,9 @@ engine this would be done by changing
888
886
  `app/controllers/blorgh/application_controller.rb` to look like:
889
887
 
890
888
  ```ruby
891
- class Blorgh::ApplicationController < ApplicationController
889
+ module Blorgh
890
+ class ApplicationController < ::ApplicationController
891
+ end
892
892
  end
893
893
  ```
894
894
 
@@ -123,7 +123,7 @@ run the following:
123
123
  $ rails --version
124
124
  ```
125
125
 
126
- If it says something like "Rails 4.2.0", you are ready to continue.
126
+ If it says something like "Rails 4.2.1", you are ready to continue.
127
127
 
128
128
  ### Creating the Blog Application
129
129
 
@@ -191,6 +191,9 @@ following in the `blog` directory:
191
191
  $ bin/rails server
192
192
  ```
193
193
 
194
+ TIP: If you are using Windows, you have to pass the scripts under the `bin`
195
+ folder directly to the Ruby interpreter e.g. `ruby bin\rails server`.
196
+
194
197
  TIP: Compiling CoffeeScript and JavaScript asset compression requires you
195
198
  have a JavaScript runtime available on your system, in the absence
196
199
  of a runtime you will see an `execjs` error during asset compilation.
@@ -199,7 +202,7 @@ Rails adds the `therubyracer` gem to the generated `Gemfile` in a
199
202
  commented line for new apps and you can uncomment if you need it.
200
203
  `therubyrhino` is the recommended runtime for JRuby users and is added by
201
204
  default to the `Gemfile` in apps generated under JRuby. You can investigate
202
- all the supported runtimes at [ExecJS](https://github.com/sstephenson/execjs#readme).
205
+ all the supported runtimes at [ExecJS](https://github.com/rails/execjs#readme).
203
206
 
204
207
  This will fire up WEBrick, a web server distributed with Ruby by default. To see
205
208
  your application in action, open a browser window and navigate to
@@ -315,9 +318,9 @@ root 'welcome#index'
315
318
  application to the welcome controller's index action and `get 'welcome/index'`
316
319
  tells Rails to map requests to <http://localhost:3000/welcome/index> to the
317
320
  welcome controller's index action. This was created earlier when you ran the
318
- controller generator (`rails generate controller welcome index`).
321
+ controller generator (`bin/rails generate controller welcome index`).
319
322
 
320
- Launch the web server again if you stopped it to generate the controller (`rails
323
+ Launch the web server again if you stopped it to generate the controller (`bin/rails
321
324
  server`) and navigate to <http://localhost:3000> in your browser. You'll see the
322
325
  "Hello, Rails!" message you put into `app/views/welcome/index.html.erb`,
323
326
  indicating that this new route is indeed going to `WelcomeController`'s `index`
@@ -350,7 +353,7 @@ Rails.application.routes.draw do
350
353
  end
351
354
  ```
352
355
 
353
- If you run `rake routes`, you'll see that it has defined routes for all the
356
+ If you run `bin/rake routes`, you'll see that it has defined routes for all the
354
357
  standard RESTful actions. The meaning of the prefix column (and other columns)
355
358
  will be seen later, but for now notice that Rails has inferred the
356
359
  singular form `article` and makes meaningful use of the distinction.
@@ -394,7 +397,7 @@ a controller called `ArticlesController`. You can do this by running this
394
397
  command:
395
398
 
396
399
  ```bash
397
- $ bin/rails g controller articles
400
+ $ bin/rails generate controller articles
398
401
  ```
399
402
 
400
403
  If you open up the newly generated `app/controllers/articles_controller.rb`
@@ -548,7 +551,7 @@ this:
548
551
 
549
552
  In this example, the `articles_path` helper is passed to the `:url` option.
550
553
  To see what Rails will do with this, we look back at the output of
551
- `rake routes`:
554
+ `bin/rake routes`:
552
555
 
553
556
  ```bash
554
557
  $ bin/rake routes
@@ -658,7 +661,7 @@ models, as that will be done automatically by Active Record.
658
661
 
659
662
  ### Running a Migration
660
663
 
661
- As we've just seen, `rails generate model` created a _database migration_ file
664
+ As we've just seen, `bin/rails generate model` created a _database migration_ file
662
665
  inside the `db/migrate` directory. Migrations are Ruby classes that are
663
666
  designed to make it simple to create and modify database tables. Rails uses
664
667
  rake commands to run migrations, and it's possible to undo a migration after
@@ -711,7 +714,7 @@ NOTE. Because you're working in the development environment by default, this
711
714
  command will apply to the database defined in the `development` section of your
712
715
  `config/database.yml` file. If you would like to execute migrations in another
713
716
  environment, for instance in production, you must explicitly pass it when
714
- invoking the command: `rake db:migrate RAILS_ENV=production`.
717
+ invoking the command: `bin/rake db:migrate RAILS_ENV=production`.
715
718
 
716
719
  ### Saving data in the controller
717
720
 
@@ -798,7 +801,7 @@ If you submit the form again now, Rails will complain about not finding the
798
801
  `show` action. That's not very useful though, so let's add the `show` action
799
802
  before proceeding.
800
803
 
801
- As we have seen in the output of `rake routes`, the route for `show` action is
804
+ As we have seen in the output of `bin/rake routes`, the route for `show` action is
802
805
  as follows:
803
806
 
804
807
  ```
@@ -828,7 +831,7 @@ class ArticlesController < ApplicationController
828
831
  def new
829
832
  end
830
833
 
831
- # snipped for brevity
834
+ # snippet for brevity
832
835
  ```
833
836
 
834
837
  A couple of things to note. We use `Article.find` to find the article we're
@@ -860,7 +863,7 @@ Visit <http://localhost:3000/articles/new> and give it a try!
860
863
  ### Listing all articles
861
864
 
862
865
  We still need a way to list all our articles, so let's do that.
863
- The route for this as per output of `rake routes` is:
866
+ The route for this as per output of `bin/rake routes` is:
864
867
 
865
868
  ```
866
869
  articles GET /articles(.:format) articles#index
@@ -884,7 +887,7 @@ class ArticlesController < ApplicationController
884
887
  def new
885
888
  end
886
889
 
887
- # snipped for brevity
890
+ # snippet for brevity
888
891
  ```
889
892
 
890
893
  And then finally, add the view for this action, located at
@@ -1266,8 +1269,8 @@ bottom of the template:
1266
1269
  ```html+erb
1267
1270
  ...
1268
1271
 
1269
- <%= link_to 'Back', articles_path %> |
1270
- <%= link_to 'Edit', edit_article_path(@article) %>
1272
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1273
+ <%= link_to 'Back', articles_path %>
1271
1274
  ```
1272
1275
 
1273
1276
  And here's how our app looks so far:
@@ -1354,7 +1357,7 @@ Then do the same for the `app/views/articles/edit.html.erb` view:
1354
1357
 
1355
1358
  We're now ready to cover the "D" part of CRUD, deleting articles from the
1356
1359
  database. Following the REST convention, the route for
1357
- deleting articles as per output of `rake routes` is:
1360
+ deleting articles as per output of `bin/rake routes` is:
1358
1361
 
1359
1362
  ```ruby
1360
1363
  DELETE /articles/:id(.:format) articles#destroy
@@ -1533,9 +1536,7 @@ class CreateComments < ActiveRecord::Migration
1533
1536
  create_table :comments do |t|
1534
1537
  t.string :commenter
1535
1538
  t.text :body
1536
-
1537
- # this line adds an integer column called `article_id`.
1538
- t.references :article, index: true
1539
+ t.references :article, index: true, foreign_key: true
1539
1540
 
1540
1541
  t.timestamps null: false
1541
1542
  end
@@ -1543,9 +1544,9 @@ class CreateComments < ActiveRecord::Migration
1543
1544
  end
1544
1545
  ```
1545
1546
 
1546
- The `t.references` line sets up a foreign key column for the association between
1547
- the two models. An index for this association is also created on this column.
1548
- Go ahead and run the migration:
1547
+ The `t.references` line creates an integer column called `article_id`, an index
1548
+ for it, and a foreign key constraint that points to the `articles` table. Go
1549
+ ahead and run the migration:
1549
1550
 
1550
1551
  ```bash
1551
1552
  $ bin/rake db:migrate
@@ -1673,8 +1674,8 @@ So first, we'll wire up the Article show template
1673
1674
  </p>
1674
1675
  <% end %>
1675
1676
 
1676
- <%= link_to 'Back', articles_path %> |
1677
- <%= link_to 'Edit', edit_article_path(@article) %>
1677
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1678
+ <%= link_to 'Back', articles_path %>
1678
1679
  ```
1679
1680
 
1680
1681
  This adds a form on the `Article` show page that creates a new comment by
@@ -1754,8 +1755,8 @@ add that to the `app/views/articles/show.html.erb`.
1754
1755
  </p>
1755
1756
  <% end %>
1756
1757
 
1757
- <%= link_to 'Edit Article', edit_article_path(@article) %> |
1758
- <%= link_to 'Back to Articles', articles_path %>
1758
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1759
+ <%= link_to 'Back', articles_path %>
1759
1760
  ```
1760
1761
 
1761
1762
  Now you can add articles and comments to your blog and have them show up in the
@@ -1820,8 +1821,8 @@ following:
1820
1821
  </p>
1821
1822
  <% end %>
1822
1823
 
1823
- <%= link_to 'Edit Article', edit_article_path(@article) %> |
1824
- <%= link_to 'Back to Articles', articles_path %>
1824
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1825
+ <%= link_to 'Back', articles_path %>
1825
1826
  ```
1826
1827
 
1827
1828
  This will now render the partial in `app/views/comments/_comment.html.erb` once
@@ -1870,8 +1871,8 @@ Then you make the `app/views/articles/show.html.erb` look like the following:
1870
1871
  <h2>Add a comment:</h2>
1871
1872
  <%= render 'comments/form' %>
1872
1873
 
1873
- <%= link_to 'Edit Article', edit_article_path(@article) %> |
1874
- <%= link_to 'Back to Articles', articles_path %>
1874
+ <%= link_to 'Edit', edit_article_path(@article) %> |
1875
+ <%= link_to 'Back', articles_path %>
1875
1876
  ```
1876
1877
 
1877
1878
  The second render just defines the partial template we want to render,
@@ -1987,7 +1988,7 @@ class ArticlesController < ApplicationController
1987
1988
  @articles = Article.all
1988
1989
  end
1989
1990
 
1990
- # snipped for brevity
1991
+ # snippet for brevity
1991
1992
  ```
1992
1993
 
1993
1994
  We also want to allow only authenticated users to delete comments, so in the
@@ -2003,7 +2004,7 @@ class CommentsController < ApplicationController
2003
2004
  # ...
2004
2005
  end
2005
2006
 
2006
- # snipped for brevity
2007
+ # snippet for brevity
2007
2008
  ```
2008
2009
 
2009
2010
  Now if you try to create a new article, you will be greeted with a basic HTTP
@@ -685,7 +685,7 @@ you can safely pass the username as set by the user:
685
685
 
686
686
  ```erb
687
687
  <%# This is safe, it is going to be escaped if needed. %>
688
- <%= t('welcome_html', username: @current_user.username %>
688
+ <%= t('welcome_html', username: @current_user.username) %>
689
689
  ```
690
690
 
691
691
  Safe strings on the other hand are interpolated verbatim.
@@ -807,7 +807,7 @@ So, for example, instead of the default error message `"cannot be blank"` you co
807
807
 
808
808
  | validation | with option | message | interpolation |
809
809
  | ------------ | ------------------------- | ------------------------- | ------------- |
810
- | confirmation | - | :confirmation | - |
810
+ | confirmation | - | :confirmation | attribute |
811
811
  | acceptance | - | :accepted | - |
812
812
  | presence | - | :blank | - |
813
813
  | absence | - | :present | - |
@@ -827,6 +827,7 @@ So, for example, instead of the default error message `"cannot be blank"` you co
827
827
  | numericality | :equal_to | :equal_to | count |
828
828
  | numericality | :less_than | :less_than | count |
829
829
  | numericality | :less_than_or_equal_to | :less_than_or_equal_to | count |
830
+ | numericality | :other_than | :other_than | count |
830
831
  | numericality | :only_integer | :not_an_integer | - |
831
832
  | numericality | :odd | :odd | - |
832
833
  | numericality | :even | :even | - |
@@ -161,7 +161,7 @@ throwing an error message. If the command is valid, a method of the same name
161
161
  is called.
162
162
 
163
163
  ```ruby
164
- COMMAND_WHITELIST = %(plugin generate destroy console server dbconsole application runner new version help)
164
+ COMMAND_WHITELIST = %w(plugin generate destroy console server dbconsole application runner new version help)
165
165
 
166
166
  def run_command!(command)
167
167
  command = parse_command(command)
@@ -29,14 +29,11 @@
29
29
  More Ruby on Rails
30
30
  </span>
31
31
  <ul class="more-info-links s-hidden">
32
- <li class="more-info"><a href="http://rubyonrails.org/">Overview</a></li>
33
- <li class="more-info"><a href="http://rubyonrails.org/download">Download</a></li>
34
- <li class="more-info"><a href="http://rubyonrails.org/deploy">Deploy</a></li>
35
- <li class="more-info"><a href="https://github.com/rails/rails">Code</a></li>
36
- <li class="more-info"><a href="http://rubyonrails.org/screencasts">Screencasts</a></li>
37
- <li class="more-info"><a href="http://rubyonrails.org/documentation">Documentation</a></li>
38
- <li class="more-info"><a href="http://rubyonrails.org/community">Community</a></li>
39
32
  <li class="more-info"><a href="http://weblog.rubyonrails.org/">Blog</a></li>
33
+ <li class="more-info"><a href="http://guides.rubyonrails.org/">Guides</a></li>
34
+ <li class="more-info"><a href="http://api.rubyonrails.org/">API</a></li>
35
+ <li class="more-info"><a href="http://stackoverflow.com/questions/tagged/ruby-on-rails">Ask for help</a></li>
36
+ <li class="more-info"><a href="https://github.com/rails/rails">Contribute on GitHub</a></li>
40
37
  </ul>
41
38
  </div>
42
39
  </div>
@@ -175,23 +175,22 @@ render template: "products/show"
175
175
 
176
176
  #### Rendering an Arbitrary File
177
177
 
178
- The `render` method can also use a view that's entirely outside of your application (perhaps you're sharing views between two Rails applications):
179
-
180
- ```ruby
181
- render "/u/apps/warehouse_app/current/app/views/products/show"
182
- ```
183
-
184
- Rails determines that this is a file render because of the leading slash character. To be explicit, you can use the `:file` option (which was required on Rails 2.2 and earlier):
178
+ The `render` method can also use a view that's entirely outside of your application:
185
179
 
186
180
  ```ruby
187
181
  render file: "/u/apps/warehouse_app/current/app/views/products/show"
188
182
  ```
189
183
 
190
- The `:file` option takes an absolute file-system path. Of course, you need to have rights to the view that you're using to render the content.
184
+ The `:file` option takes an absolute file-system path. Of course, you need to have rights
185
+ to the view that you're using to render the content.
186
+
187
+ NOTE: Using the `:file` option in combination with users input can lead to security problems
188
+ since an attacker could use this action to access security sensitive files in your file system.
191
189
 
192
190
  NOTE: By default, the file is rendered using the current layout.
193
191
 
194
- TIP: If you're running Rails on Microsoft Windows, you should use the `:file` option to render a file, because Windows filenames do not have the same format as Unix filenames.
192
+ TIP: If you're running Rails on Microsoft Windows, you should use the `:file` option to
193
+ render a file, because Windows filenames do not have the same format as Unix filenames.
195
194
 
196
195
  #### Wrapping it up
197
196