# DHH presentation: how to actually create the membership

**URL:** <https://www.ruby-forum.com/t/dhh-presentation-how-to-actually-create-the-membership/70941>\
**Category:** Rails\
**Created:** [October 4, 2006, 4:28am UTC](https://www.ruby-forum.com/t/dhh-presentation-how-to-actually-create-the-membership/70941 "2006-10-04T04:28:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [October 4, 2006, 4:28am UTC](https://www.ruby-forum.com/t/dhh-presentation-how-to-actually-create-the-membership/70941/1 "2006-10-04T04:28:25Z")

</div>

I have followed tutorials and the dhh presentaion for creating my  
application but i get a bit stuck on creating and deleting the  
relationships between items.  
eg  
user - memberships - groups

page 21 of the dhh presentation has this, though im not sure how to  
create this post from a link\_to?

#POST /memberships?group\_id=1&user\_id=2

with this delete action it appears that the membership id is already  
known  
#DELETE /memberships/3

would be great to see an example of this

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [October 4, 2006, 10:06am UTC](https://www.ruby-forum.com/t/dhh-presentation-how-to-actually-create-the-membership/70941/2 "2006-10-04T10:06:33Z")

</div>

thanks for the reply.

That partly worked.

127.0.0.1 - - [04/Oct/2006:21:01:02 New Zealand Standard Time] “POST  
/memberships?user\_id=1 HTTP/1.1” 302 117  
[http://localhost:3000/categories/1/products/2/parts](http://localhost:3000/categories/1/products/2/parts) →   
/memberships?user\_id=1

i am having to pass the group\_id through session. As it is trimmed from  
the url, see the console output above. Checking this further i added a  
‘puts’ line to show the values of the user\_id and group\_id:

puts params[:group\_id] \>\> nil  
puts params[:user\_id] \>\> 1

The shortcut version your refering to is the named route  
new\_membership\_path. I get an error when using this.

---

<div class="post-metadata">

**Author:** ![adammontgomery](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ce7236/32.png) [@adammontgomery](https://www.ruby-forum.com/u/adammontgomery)\
**Post date:** [October 4, 2006, 7:59am UTC](https://www.ruby-forum.com/t/dhh-presentation-how-to-actually-create-the-membership/70941/3 "2006-10-04T07:59:41Z")

</div>

On Oct 4, 2006, at 4:28, Adam M. wrote:

> page 21 of the dhh presentation has this, though im not sure how to  
> create this post from a link\_to?
> 
> #POST /memberships?group\_id=1&user\_id=2

In general it can be achieved using: link\_to(‘Foo’, {:controller =\>  
‘memberships’, :group\_id =\> 1, :user\_id =\> 2}, :method =\> ‘post’)

I believe there’s some shortcut when using the REST stuff, but I  
can’t recall how it’d look now.

–  
Jakob S. - [http://mentalized.net](http://mentalized.net)
