cooker.kang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2013-May-23 00:25 UTC
problem of respond_with working on nested resources
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2348d2e4-9572-49d4-9a3a-7d91101f1e0d%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
cooker.kang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2013-May-23 00:25 UTC
problem of respond_with working on nested resources
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/13b6ac50-6e21-49bf-8bde-2f38868b7da1%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.