hi all:
when using namespace or nested resources in routes.rb,such as "namespace :admin { resources :books }, we can use [:admin,@book] way to generate path. It works fine in form_for , but when I use it with respond_with in controller, I get problems.
The problem is when I put following code in controller:
def create
@book=Book.find(params[:id])
@book.save
respond_with[:admin,@book]
end
if there are some problems and the @book is not saved, the function should render new action, hence we can get error messages, but now it render index action. and the log file said it got a error 302. if I replace ‘respond_with [ :admin,@book]’ with 'respond_with @book,:location=>admin_book_path(@book)", it works fine.
should we not use “[:admin,@book]” way with respond_with?
thanks