# Rails - references?

**URL:** <https://www.ruby-forum.com/t/rails-references/193267>\
**Category:** Rails\
**Created:** [August 14, 2010, 2:22pm UTC](https://www.ruby-forum.com/t/rails-references/193267 "2010-08-14T14:22:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 2:22pm UTC](https://www.ruby-forum.com/t/rails-references/193267/1 "2010-08-14T14:22:49Z")

</div>

Following this tutorial:

> **[Getting Started with Rails — Ruby on Rails Guides](https://edgeguides.rubyonrails.org/getting_started.html)**
>
> Getting Started with RailsThis guide covers getting up and running with Ruby on Rails.After reading this guide, you will know: How to install Rails, create a new Rails application, and connect your application to a database. The general layout of a...

Under; 7.1 Generating a Model

It mentions the following for creating a “Comment” model:

$ rails generate model Comment commenter:string body:text  
post:references

In post:references

What is “references”? Is it a data type? And, what does it represent?

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 2:26pm UTC](https://www.ruby-forum.com/t/rails-references/193267/2 "2010-08-14T14:26:25Z")

</div>

I saw down few lines in the tutorial the following:

The t.references line sets up a foreign key column for the association  
between the two models. Go ahead and run the migration:

So, is “references” simply a “Foreign key”?

Thanks.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 2:38pm UTC](https://www.ruby-forum.com/t/rails-references/193267/3 "2010-08-14T14:38:35Z")

</div>

On 14 August 2010 13:26, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I saw down few lines in the tutorial the following:
> 
> The t.references line sets up a foreign key column for the association  
> between the two models. Go ahead and run the migration:

So did you go ahead and run it? What did it generate in the db for this  
field?

Colin

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 4:47pm UTC](https://www.ruby-forum.com/t/rails-references/193267/4 "2010-08-14T16:47:57Z")

</div>

On 14 August 2010 13:48, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Colin
> 
> I found that there is a “post\_id” column in the “comments” table.

There you are then, presumably in the example Comment belongs\_to Post,  
so this is generating the foreign key field for the post. Question  
answered.

Colin

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 4:59pm UTC](https://www.ruby-forum.com/t/rails-references/193267/5 "2010-08-14T16:59:58Z")

</div>

clanlaw wrote:

> On 14 August 2010 13:48, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > Colin
> > 
> > I found that there is a “post\_id” column in the “comments” table.
> 
> There you are then, presumably in the example Comment belongs\_to Post,  
> so this is generating the foreign key field for the post. Question  
> answered.
> 
> Colin

What do you mean by run it?

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 2:48pm UTC](https://www.ruby-forum.com/t/rails-references/193267/6 "2010-08-14T14:48:08Z")

</div>

Colin L. wrote:

> On 14 August 2010 13:26, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > I saw down few lines in the tutorial the following:
> > 
> > The t.references line sets up a foreign key column for the association  
> > between the two models. Go ahead and run the migration:
> 
> So did you go ahead and run it? What did it generate in the db for this  
> field?
> 
> Colin

I found that there is a “post\_id” column in the “comments” table.

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 5:07pm UTC](https://www.ruby-forum.com/t/rails-references/193267/7 "2010-08-14T17:07:17Z")

</div>

On 14 August 2010 15:59, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Colin
> 
> What do you mean by run it?

What do you mean, “what do you mean by run it?”? I don’t see any  
reference to running anything in my post.

Colin

---

<div class="post-metadata">

**Author:** ![swengineer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/97f17d/32.png) [@swengineer](https://www.ruby-forum.com/u/swengineer)\
**Post date:** [August 14, 2010, 5:26pm UTC](https://www.ruby-forum.com/t/rails-references/193267/8 "2010-08-14T17:26:44Z")

</div>

clanlaw wrote:

> On 14 August 2010 15:59, Abder-Rahman A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > Colin
> > 
> > What do you mean by run it?
> 
> What do you mean, “what do you mean by run it?”? I don’t see any  
> reference to running anything in my post.
> 
> Colin

This is when you said: So did you go ahead and “run it”? What did it  
generate in the db for this field?

But, anyway, I got the idea now.

Thanks.
