Hi,

Thanks for responding, but that's not really what I was looking
for.     My basic problem is that I don't understand how to correctly
distinguish between user creation and assignment of a user to a group
using RESTFUL routes.    It appears to me that with nested routes, you
end up with users#create in both cases.

Stan



On Aug 20, 11:44 am, Hendra Gunawan <[email protected]> wrote:
> I'm not sure what do you mean... but maybe this sample code will help you...
> :-)
>
> resources :groups do
>    resources :users      # using nested routes :-)
> end
>
> It will generate url like this
> new_group_user      GET          /groups/:group_id/users/new(.:format)
>    {:action=>"new", :controller=>"users"}
>
> You can see the detail with "rake routes"
>
> :-)
>
> On Sat, Aug 20, 2011 at 7:35 PM, Stan McFarland <
>
>
>
>
>
>
>
> [email protected]> wrote:
> > Hi, Rails newbie here.
>
> > If I have a basic HABTM association - say, users and groups - I can't
> > get my head around the RESTful routing required to add a user to a
> > group.
>
> > POST /user  will call  user#create
> > POST /group will call group#create
> > POST /group/:group_id/user should call:   what?     Is it ok to define
> > a "addUser" action to the group controller?  Or should I test for the
> > existence of the group_id in the user#create method and then proceed
> > accordingly?    I want to do things the Rails way but sometimes my PHP
> > experience comes back to haunt me. :)
>
> > Thanks,
>
> > Stan
>
> > --
> > 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected].
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to