# RESTful route question

**URL:** <https://www.ruby-forum.com/t/restful-route-question/185124>\
**Category:** Rails\
**Created:** [March 14, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/restful-route-question/185124 "2010-03-14T16:51:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 14, 2010, 4:51pm UTC](https://www.ruby-forum.com/t/restful-route-question/185124/1 "2010-03-14T16:51:20Z")

</div>

I have in routes.rb

map.resources :labs, :collection =\> { :group =\> :get }

which is working. But when I try to pass a parameter, e.g.

\<% form\_tag group\_labs\_path( :patient\_id =\> @patient.id ), :method  
=\> :get do %\>

The :patient\_id isn’t getting passed to the controller:

— !map:HashWithIndifferentAccess  
group: !map:HashWithIndifferentAccess  
id: “5”  
commit: Add Lab  
action: group  
controller: labs

Doing it the non-restful way works:

\<% form\_tag :action =\> :group, :patient\_id =\> @patient.id, :method  
=\> :get do %\>

— !map:HashWithIndifferentAccess  
group: !map:HashWithIndifferentAccess  
id: “6”  
commit: Add Lab  
method: get  
authenticity\_token: …  
action: group  
patient\_id: “8”  
controller: labs

Any idea how to configure the route to pass the parameter?

Many TIA,  
Craig

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 15, 2010, 2:00pm UTC](https://www.ruby-forum.com/t/restful-route-question/185124/2 "2010-03-15T14:00:45Z")

</div>

Have you tried just making a hidden field for the patient id? Since  
you’re submitting a form as a GET request, it should post all form  
data in the URL.

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 15, 2010, 7:16pm UTC](https://www.ruby-forum.com/t/restful-route-question/185124/3 "2010-03-15T19:16:20Z")

</div>

On Mar 15, 7:59 am, daphonz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Have you tried just making a hidden field for the patient id?

That’s an interesting design thought, which I’ll play with. But it  
seems to me I should still be able to configure the route in a RESTful  
way. Any idea how?

---

<div class="post-metadata">

**Author:** ![Dudebot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e495f1/32.png) [@Dudebot](https://www.ruby-forum.com/u/Dudebot)\
**Post date:** [March 16, 2010, 1:20pm UTC](https://www.ruby-forum.com/t/restful-route-question/185124/4 "2010-03-16T13:20:14Z")

</div>

> On Mar 15, 7:59 am, daphonz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Have you tried just making a hidden field for the patient id?

BTW

\<% form\_tag group\_labs\_path, :method =\> :get do %\>  
\<%= hidden\_field\_tag :patient\_id, @patient.id %\>

works perfectly of course 🙂 (Thanks!)

But I still don’t understand why

\<% form\_tag group\_labs\_path( :patient\_id =\> @patient.id ), :method  
=\> :get do %\>

isn’t permitted syntax. Someday I’ll understand RESTful routes, but  
not today 🙂
