Hi guys,
let’s say I have a nested route, like User > Roles
map.resources :user, :has_many => [ :roles ]
In this case, calling new_user_role_url gets me to the role controller’s :create method with a user_id set in the parameters. Is there a better way to handle the creation of this role object automatically in the User object’s :roles association or I just have to resort to the good old method of finding the appropriate user object first and add the new role object to it’s association proxy:
@user = User.find(params[:id])
@user.roles << Role.create(params[:role])
Any ideas would be appreciated.
Regards,
András