diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-13 11:51:10 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-05-13 11:51:10 -0700 |
commit | d53b5f073924e8b397ec86f7ad092aa0b5ed3fe4 (patch) | |
tree | 78d2f76516e22944e2c41e318a0d54d5ad639289 /guides/source/getting_started.md | |
parent | b97ff316ec6d3fa962dc804d5aeb83aa81b2d847 (diff) | |
parent | 37ca5b09662797928a4f74878595a4e577c5aedd (diff) | |
download | rails-d53b5f073924e8b397ec86f7ad092aa0b5ed3fe4.tar.gz rails-d53b5f073924e8b397ec86f7ad092aa0b5ed3fe4.tar.bz2 rails-d53b5f073924e8b397ec86f7ad092aa0b5ed3fe4.zip |
Merge branch 'master' into normalizecb
* master: (61 commits)
add tests for reset_calbacks
Fixing build broken by this change
Extract variable out of loop
Updated comment to Rails 4
Fixes NoMethodError: `alias_method_chain` when requiring just active_support/core_ext
better error message when app name is not passed in `rails new`
Code cleanup for ActionDispatch::Flash#call
Fix typo: require -> requires
Add CHANGELOG entry for #10576
Merge pull request #10556 from Empact/deprecate-schema-statements-distinct
Some editorial changes on the documentation.
respond_to -> respond to in a message from AM::Lint
specify that dom_(id|class) are deprecated in controllers, views are fine
copy edits [ci skip]
Fix class and method name typos
Replace multi_json with json
ruby -> Ruby
Adding documentation to the automatic inverse_of finder.
Improve CHANGELOG entry [ci kip]
Call assume_migrated_upto_version on connection
...
Conflicts:
activesupport/lib/active_support/callbacks.rb
Diffstat (limited to 'guides/source/getting_started.md')
-rw-r--r-- | guides/source/getting_started.md | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/guides/source/getting_started.md b/guides/source/getting_started.md index 46115afb8c..599e47949d 100644 --- a/guides/source/getting_started.md +++ b/guides/source/getting_started.md @@ -29,7 +29,7 @@ prerequisites installed: Rails is a web application framework running on the Ruby programming language. If you have no prior experience with Ruby, you will find a very steep learning curve diving straight into Rails. There are some good free resources on the -internet for learning Ruby, including: +Internet for learning Ruby, including: * [Mr. Neighborly's Humble Little Ruby Book](http://www.humblelittlerubybook.com) * [Programming Ruby](http://www.ruby-doc.org/docs/ProgrammingRuby/) @@ -853,8 +853,7 @@ it look as follows: ```html+erb <h1>Editing post</h1> -<%= form_for :post, url: post_path(@post.id) }, -method: :patch do |f| %> +<%= form_for :post, url: post_path(@post.id), method: :patch do |f| %> <% if @post.errors.any? %> <div id="errorExplanation"> <h2><%= pluralize(@post.errors.count, "error") %> prohibited @@ -934,7 +933,7 @@ appear next to the "Show" link: <tr> <td><%= post.title %></td> <td><%= post.text %></td> - <td><%= link_to 'Show', post_path %></td> + <td><%= link_to 'Show', post_path(post) %></td> <td><%= link_to 'Edit', edit_post_path(post) %></td> </tr> <% end %> @@ -1076,7 +1075,7 @@ together. <tr> <td><%= post.title %></td> <td><%= post.text %></td> - <td><%= link_to 'Show', post_path %></td> + <td><%= link_to 'Show', post_path(post) %></td> <td><%= link_to 'Edit', edit_post_path(post) %></td> <td><%= link_to 'Destroy', post_path(post), method: :delete, data: { confirm: 'Are you sure?' } %></td> @@ -1149,19 +1148,17 @@ class CreateComments < ActiveRecord::Migration create_table :comments do |t| t.string :commenter t.text :body - t.references :post + t.references :post, index: true t.timestamps end - - add_index :comments, :post_id end end ``` The `t.references` line sets up a foreign key column for the association between -the two models. And the `add_index` line sets up an index for this association -column. Go ahead and run the migration: +the two models. An index for this association is also created on this column. +Go ahead and run the migration: ```bash $ rake db:migrate @@ -1173,10 +1170,8 @@ run against the current database, so in this case you will just see: ```bash == CreateComments: migrating ================================================= -- create_table(:comments) - -> 0.0008s --- add_index(:comments, :post_id) - -> 0.0003s -== CreateComments: migrated (0.0012s) ======================================== + -> 0.0115s +== CreateComments: migrated (0.0119s) ======================================== ``` ### Associating Models |