在routes.rb中我有:Rails的路由錯誤
get "survey/show" => "survey#show"
post "survey/step_2" => "survey#step_2"
post "survey/step_3" => "survey#step_3"
而在step_2.html.erb我:
<%= form_for @result, :url => { :controller => 'survey', :action => 'step_3' } do |f| %>
而在survey_controller.rb我:
def step_2
@result = Result.new(params[:result])
if @result.save
session[:result_id] = @result.id
render :action => "step_2"
else
render :action => "show"
end
end
def step_3
@result = Result.find(session[:result_id])
if @result.update_attributes(params[:result])
render :action => "step_3"
else
render :action => "step_2"
end
end
而當我在步驟2上提交表單時,出現以下錯誤: No route matches "/survey/step_3"
你確定你正在請求是一個POST請求。根據您的路線定義,獲取調查/步驟_3的請求將被拒絕。 – codinguser 2011-05-15 02:59:19