Forum: Ruby on Rails problem of respond_with working on nested resources

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
unknown (Guest)
on 2013-05-23 02:27
(Received via mailing list)
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

    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
'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?

This topic is locked and can not be replied to.