# RESTful new method

**URL:** <https://www.ruby-forum.com/t/restful-new-method/180907>\
**Category:** Rails\
**Created:** [December 31, 2009, 9:49am UTC](https://www.ruby-forum.com/t/restful-new-method/180907 "2009-12-31T09:49:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [December 31, 2009, 9:49am UTC](https://www.ruby-forum.com/t/restful-new-method/180907/1 "2009-12-31T09:49:53Z")

</div>

I have a RESTful implementation. The index view shows a table with  
two columns: 1) Site\_id and 2) URL to create a New Review for the  
corresponding site\_id. Each row of the table is rendered using a  
partial.

If the URL is clicked, a form is presented by the “new” method to  
create a new review for a site. Right now I only know to generate  
each URL with new\_review\_path, which creates the same URL for all  
rows, leading to a black form to create a new review.

I want this form to be prefilled with the value of the corresponding  
site\_id in the site\_id column. That means somehow each URL to create  
a new review has to be different from one another. How can I do this?

Thanks

Vincent

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [December 31, 2009, 9:52am UTC](https://www.ruby-forum.com/t/restful-new-method/180907/2 "2009-12-31T09:52:48Z")

</div>

sorry, I meant right now I only know to generate each URL with  
new\_review\_path, which creates the same URL for all rows, leading to a  
blank form to create a new review. I would like each form to be  
prefilled with the corresponding site\_id. thanks.

On Dec 31, 12:48 am, Vincent P [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want this form to be prefilled with the value of the corresponding  
> site\_id in the site\_id column. That means somehow each URL to create  
> a new review has to be different from one another. How can I do this?
> 
> Thanks
> 
> Vincent

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [December 31, 2009, 6:32pm UTC](https://www.ruby-forum.com/t/restful-new-method/180907/3 "2009-12-31T18:32:38Z")

</div>

Learn by Doing wrote:

> I have a RESTful implementation. The index view shows a table with  
> two columns: 1) Site\_id and 2) URL to create a New Review for the  
> corresponding site\_id. Each row of the table is rendered using a  
> partial.
> 
> If the URL is clicked, a form is presented by the “new” method to  
> create a new review for a site. Right now I only know to generate  
> each URL with new\_review\_path, which creates the same URL for all  
> rows, leading to a black form to create a new review.
> 
> I want this form to be prefilled with the value of the corresponding  
> site\_id in the site\_id column. That means somehow each URL to create  
> a new review has to be different from one another. How can I do this?

Read up on nested resources. That’s how I would most likely implement  
something like what you describe.

> **[Rails Routing from the Outside In — Ruby on Rails Guides](https://guides.rubyonrails.org/routing.html#nested-routes)**
>
> Rails Routing from the Outside InThis guide covers the user-facing features of Rails routing.After reading this guide, you will know: How to interpret the code in config/routes.rb. How to construct your own routes, using either the preferred...

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [December 31, 2009, 8:49pm UTC](https://www.ruby-forum.com/t/restful-new-method/180907/4 "2009-12-31T20:49:29Z")

</div>

Thanks Robert. Unfortunately, I already implemented the site model not  
using REST and the review model as REST but standing alone not belonging  
to  
another REST model. Is there any other way around this? Thanks.

---

<div class="post-metadata">

**Author:** ![Learn\_by\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/e274bd/32.png) [@Learn\_by\_D](https://www.ruby-forum.com/u/Learn_by_D)\
**Post date:** [January 4, 2010, 2:42am UTC](https://www.ruby-forum.com/t/restful-new-method/180907/5 "2010-01-04T02:42:54Z")

</div>

I finally figured out that I need to pass these things through  
params.

Thanks.

On Dec 31 2009, 11:48 am, “Easebus” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Subject: [Rails] Re: RESTful new method
> 
> > rows, leading to a black form to create a new review.  
> > Posted viahttp://www.ruby-forum.com/.

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
