aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/association_basics.md
diff options
context:
space:
mode:
authorraq929 <raq929@users.noreply.github.com>2015-11-01 16:57:24 -0500
committerraq929 <raq929@users.noreply.github.com>2015-11-01 16:57:24 -0500
commitaaddae48e2d2e5e160aeb3e4bf72fd19d2cca278 (patch)
tree23f2535910156adb723d851d567ee9b3cfb4a2a6 /guides/source/association_basics.md
parent46b08da0eaccf1af4d69d01efa7f01e58ee3ca67 (diff)
downloadrails-aaddae48e2d2e5e160aeb3e4bf72fd19d2cca278.tar.gz
rails-aaddae48e2d2e5e160aeb3e4bf72fd19d2cca278.tar.bz2
rails-aaddae48e2d2e5e160aeb3e4bf72fd19d2cca278.zip
Update association_basics.md
Moves the definition of an association to the top of the page. I am just starting to learn Rails, and having this definition at the top instead of in the second section would be really useful. Updates the Types of Associations section for clarity. Moves the list of associations before the explanation. Links to wikipedia articles on Primary and Foreign keys.
Diffstat (limited to 'guides/source/association_basics.md')
-rw-r--r--guides/source/association_basics.md6
1 files changed, 4 insertions, 2 deletions
diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md
index 74cd9bdc7b..996050d667 100644
--- a/guides/source/association_basics.md
+++ b/guides/source/association_basics.md
@@ -16,7 +16,7 @@ After reading this guide, you will know:
Why Associations?
-----------------
-Why do we need associations between models? Because they make common operations simpler and easier in your code. For example, consider a simple Rails application that includes a model for customers and a model for orders. Each customer can have many orders. Without associations, the model declarations would look like this:
+In Rails, an _association_ is a connection between two Active Record models. Why do we need associations between models? Because they make common operations simpler and easier in your code. For example, consider a simple Rails application that includes a model for customers and a model for orders. Each customer can have many orders. Without associations, the model declarations would look like this:
```ruby
class Customer < ActiveRecord::Base
@@ -71,7 +71,7 @@ To learn more about the different types of associations, read the next section o
The Types of Associations
-------------------------
-In Rails, an _association_ is a connection between two Active Record models. Associations are implemented using macro-style calls, so that you can declaratively add features to your models. For example, by declaring that one model `belongs_to` another, you instruct Rails to maintain Primary Key-Foreign Key information between instances of the two models, and you also get a number of utility methods added to your model. Rails supports six types of associations:
+Rails supports six types of associations:
* `belongs_to`
* `has_one`
@@ -80,6 +80,8 @@ In Rails, an _association_ is a connection between two Active Record models. Ass
* `has_one :through`
* `has_and_belongs_to_many`
+Associations are implemented using macro-style calls, so that you can declaratively add features to your models. For example, by declaring that one model `belongs_to` another, you instruct Rails to maintain [Primary Key](https://en.wikipedia.org/wiki/Unique_key)-[Foreign Key](https://en.wikipedia.org/wiki/Foreign_key) information between instances of the two models, and you also get a number of utility methods added to your model.
+
In the remainder of this guide, you'll learn how to declare and use the various forms of associations. But first, a quick introduction to the situations where each association type is appropriate.
### The `belongs_to` Association