2012-09-04 85 views
0

如何render :new並將位置設置爲question/:id/new/answer如何渲染一個動作並在Rails 3中設置URL?

render :location => new_question_path設置位置question/:id/answer

render :location => "/question/#{params[:id]}/new/answer"也不能工作。

相關路線:get '/question/:id/new/answer' => 'answers#new', as: :new_answer

+1

的路徑,你可以發佈您的routes.rb? –

+0

不應該是'render:location =>「/ question /#{params [:id]}/answer/new」'而不是? –

回答

2

可能使用

resources :questions do 
    get 'new/answer', :on => :member 
end 

,並會看到通過rake routes