Hi, can anyone help with a routing problem for nested resources:
My models are User (has_one :house) and House (belongs_to :user).
I have a houses_controller and a user_house_controller. house_controller
is for the admin to perform CRUD on houses; so users' CRUD must go
through the user_house_controller.
The resources are nested like so:
map.resources :users do |users|
users.resource :house, :controller => 'user_house'
So after a new user registers I want to send him to the form for the his
I'm having trouble with generating this URL programmatically. In my
users_controller I have:
@user = User.new(params[:user]) #user registered, now register his
redirect_to new_gym_url(:user_id => @user)
I know when one has a nested resource then the URL generator takes 2
arguments: The nested-under model and the nested model. So according to
this logic, the URL helper should look like:
new_gym_url(:user_id => @user, :id => house)
But then I will be referring to a house that hasn't been created yet!
When I just use:
new_gym_url(:user_id => @user) or new_gym_url
I get redirected to the houses_controller#new, and I want to use
This is about to drive me nuts; so please explain!