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

72a6d1c2016a6ec343248690d4a9eb52?d=identicon&s=25 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?

Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.