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
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 →
/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.
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