# Help with routes and params

**URL:** <https://www.ruby-forum.com/t/help-with-routes-and-params/159885>\
**Category:** Rails\
**Created:** [February 9, 2009, 7:46pm UTC](https://www.ruby-forum.com/t/help-with-routes-and-params/159885 "2009-02-09T19:46:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [February 9, 2009, 7:46pm UTC](https://www.ruby-forum.com/t/help-with-routes-and-params/159885/1 "2009-02-09T19:46:56Z")

</div>

I need some help with routes and params. I am developming some forums  
for a web. I want to be able to create new replies once a post has been  
created. So I create a post and then I have to put a link named “Reply”.  
What I want to do is Reply.create, and pass post\_id as a param to this  
Reply.create action. How can I make this link? How can I get this param  
in replies controller?  
I think I can create a whole new action, but I would like to use  
Reply.create.

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [February 9, 2009, 10:27pm UTC](https://www.ruby-forum.com/t/help-with-routes-and-params/159885/2 "2009-02-09T22:27:05Z")

</div>

Hi John,

I highly suggest you take a peek as the associations that Rails  
provides. A good place to start is the Rails Guides.

> **[Active Record Associations — Ruby on Rails Guides](https://guides.rubyonrails.org/association_basics.html)**
>
> Active Record AssociationsThis guide covers the association features of Active Record.After reading this guide, you will know: How to declare associations between Active Record models. How to understand the various types of Active Record...

and also the guide on routes (particularly the part on nested  
resources)  
[http://guides.rubyonrails.org/routing\_outside\_in.html](http://guides.rubyonrails.org/routing_outside_in.html)  
These will make life much easier for you if you follow them.

Sorry for not really answering your question… 🙂

Again, I would go this route though. 🙂  
On Feb 9, 12:46 pm, John S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![captaffy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/f04885/32.png) [@captaffy](https://www.ruby-forum.com/u/captaffy)\
**Post date:** [February 9, 2009, 11:20pm UTC](https://www.ruby-forum.com/t/help-with-routes-and-params/159885/3 "2009-02-09T23:20:00Z")

</div>

I think you have to have a look at Rails basics. A basic forum would  
be something like:

forums has\_many categories  
categories has\_many topics  
topics has\_many replies

then you have has\_many routes like /forums/1/categories/1/topic and in  
your routes.rb you would do

map.resources :forums do |forum|  
forum.resources :categories do |cat|  
cat.resources :topics  
end  
end

You could add :has\_many =\> :topics but if you need members and/or  
collections later its better this way.
