Rails - references?

Following this tutorial:
http://edgeguides.rubyonrails.org/getting_started.html

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.

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.

On 14 August 2010 13:26, Abder-Rahman A. [email protected] 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

On 14 August 2010 13:48, Abder-Rahman A. [email protected] 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

clanlaw wrote:

On 14 August 2010 13:48, Abder-Rahman A. [email protected] 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?

Colin L. wrote:

On 14 August 2010 13:26, Abder-Rahman A. [email protected] 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.

On 14 August 2010 15:59, Abder-Rahman A. [email protected] 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

clanlaw wrote:

On 14 August 2010 15:59, Abder-Rahman A. [email protected] 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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs