diff options
author | Claudio B <claudiob@users.noreply.github.com> | 2016-02-25 08:30:53 -0800 |
---|---|---|
committer | Claudio B <claudiob@users.noreply.github.com> | 2016-02-25 08:30:53 -0800 |
commit | 1f8ce32edcce503490aa873dd49788c6fd79c135 (patch) | |
tree | c4c63149d6769d19c0ebbb8f081399c4c86b93bb /guides | |
parent | 2fda4e0874a97a76107ab9e88305169f2c625933 (diff) | |
parent | 569dc54a151175c22f5dcff3811dbaeecfbfd12d (diff) | |
download | rails-1f8ce32edcce503490aa873dd49788c6fd79c135.tar.gz rails-1f8ce32edcce503490aa873dd49788c6fd79c135.tar.bz2 rails-1f8ce32edcce503490aa873dd49788c6fd79c135.zip |
Merge pull request #23889 from claudiob/fix-getting-started
Doc: update guides for Rails 5
Diffstat (limited to 'guides')
-rw-r--r-- | guides/source/getting_started.md | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 8eb3b6190f..4431512eda 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -298,26 +298,30 @@ Open the file `config/routes.rb` in your editor. Rails.application.routes.draw do get 'welcome/index' - # The priority is based upon order of creation: - # first created -> highest priority. - # See how all your routes lay out with "bin/rails routes". - # - # You can have the root of your site routed with "root" - # root 'welcome#index' - # - # ... + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + # Serve websocket cable requests in-process + # mount ActionCable.server => '/cable' +end ``` This is your application's _routing file_ which holds entries in a special [DSL (domain-specific language)](http://en.wikipedia.org/wiki/Domain-specific_language) that tells Rails how to connect incoming requests to -controllers and actions. This file contains many sample routes on commented -lines, and one of them actually shows you how to connect the root of your site -to a specific controller and action. Find the line beginning with `root` and -uncomment it. It should look something like the following: +controllers and actions. +Edit this file by adding the line of code `root 'welcome#index'`. +It should look something like the following: ```ruby -root 'welcome#index' +Rails.application.routes.draw do + get 'welcome/index' + + # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html + + # Serve websocket cable requests in-process + # mount ActionCable.server => '/cable' + root 'welcome#index' +end ``` `root 'welcome#index'` tells Rails to map requests to the root of the @@ -348,7 +352,7 @@ operations are referred to as _CRUD_ operations. Rails provides a `resources` method which can be used to declare a standard REST resource. You need to add the _article resource_ to the -`config/routes.rb` as follows: +`config/routes.rb` so the file will look as follows: ```ruby Rails.application.routes.draw do @@ -625,7 +629,7 @@ end The `render` method here is taking a very simple hash with a key of `:plain` and value of `params[:article].inspect`. The `params` method is the object which represents the parameters (or fields) coming in from the form. The `params` -method returns an `ActiveSupport::HashWithIndifferentAccess` object, which +method returns an `ActionController::Parameters` object, which allows you to access the keys of the hash using either strings or symbols. In this situation, the only parameters that matter are the ones from the form. @@ -635,7 +639,7 @@ If you re-submit the form one more time you'll now no longer get the missing template error. Instead, you'll see something that looks like the following: ```ruby -{"title"=>"First article!", "text"=>"This is my first article."} +<ActionController::Parameters {"title"=>"First Article!", "text"=>"This is my first article."} permitted: false> ``` This action is now displaying the parameters for the article that are coming in |