Assume we’ve got a namespace of Customer and in that a controller for Organisations.
This doesn’t work
class Customer::OrganisationsController < ApplicationController respond_to :html def update @organisation = Organisation.find(params[:id]) @organisation.update_attributes(params[:organisation]) respond_with [:customer,@organisation] end end
It redirects to the customer_organisation show method without checking for errors. I think it should work, but the respond_with code doesn’t handle it properly. Instead, try this:
class Customer::OrganisationsController < ApplicationController respond_to :html def update @organisation = Organisation.find(params[:id]) @organisation.update_attributes(params[:organisation]) respond_with @organisation, :location => customer_organisation_url(@organisation) end end
I’m not sure it’s annoying enough to want to patch it. There are a lot of edge cases in Rails in general around name spaces. Also, note it’s not just update that needs this but also create.
Imported Comments:
malclocke
respond_with :customer, @organisation should work, without the square brackets