# About association

**URL:** <https://www.ruby-forum.com/t/about-association/148693>\
**Category:** Rails\
**Created:** [September 16, 2008, 9:11am UTC](https://www.ruby-forum.com/t/about-association/148693 "2008-09-16T09:11:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nn2000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nn2000](https://www.ruby-forum.com/u/nn2000)\
**Post date:** [September 16, 2008, 9:11am UTC](https://www.ruby-forum.com/t/about-association/148693/1 "2008-09-16T09:11:11Z")

</div>

I am building a blog, an event has many comments and a comment belong to  
an event.  
But each comment I created under different events all got different id.  
For example, if I can access url:  
[http://localhost:3000/event/1/comments/1](http://localhost:3000/event/1/comments/1), then I cannot have access  
[http://localhost:3000/event/2/comments/1](http://localhost:3000/event/2/comments/1). Because the first comment  
created under event2 had id 2.  
How to fix that?

---

<div class="post-metadata">

**Author:** ![nn2000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nn2000](https://www.ruby-forum.com/u/nn2000)\
**Post date:** [September 16, 2008, 10:38am UTC](https://www.ruby-forum.com/t/about-association/148693/2 "2008-09-16T10:38:08Z")

</div>

Don’t understand your problem.

The id is an autoincrement field and of course each  
comment gets it’s own id. The association is (or should be)  
defined by the events\_id field in the comments table.

Please provide your code how you’ve defined the  
association in the model and how you create  
the new comments in the controller…

---

<div class="post-metadata">

**Author:** ![nn2000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nn2000](https://www.ruby-forum.com/u/nn2000)\
**Post date:** [September 16, 2008, 10:45am UTC](https://www.ruby-forum.com/t/about-association/148693/3 "2008-09-16T10:45:47Z")

</div>

Please only ask questions in one spot (either [railsforum.com](http://railsforum.com) or the  
mailing list, not both)

## Your question had already been answered here: [http://railsforum.com/viewtopic.php?pid=75146#p75146](http://railsforum.com/viewtopic.php?pid=75146#p75146)

Ryan B.  
Freelancer  
Skype: radarlistener  
MSN & Gtalk: removed\_email\_address@domain.invalid
