I have setup some simple associations in my rails app:
resources :properties do
resources :units
end
After updating a unit:
'localhost:3000/properties/2/units/3/edit'
I want to be redirected back to the appropriate location.
after I click "Update" I am redirected back to:
'localhost:3000/units/3', but should go to 'localhost:3000/properties/2/units/3/'
In my units controller, I have:
if @unit.update_attributes(params[:unit])
format.html { redirect_to(property_units_path(@property, @unit), :notice => 'Unit was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @unit.errors, :status => :unprocessable_entity }
end
Is this the appropriate use in my redirect_to function? I am still trying to become familiar with how the routes work but I feel like this should work?
Thanks!