0
下面是index.html.erb代碼:PARAMS不獲取任何沿ERB通過
<%= link_to 'Back', '/[email protected]_to&index=0' %>
這裏是在routes.rb中/ url_handler映射:
match '/url_handler', :to => 'application#url_handler'
這裏在應用控制器,用於url_handler的代碼:
def url_handler
url = params[:url]
index = params[:index]
if index == 1 then
step_forward(url)
elsif index == 0 then
step_back
end
redirect_to url
end
private
#record path to current page
def step_forward(current_path)
session[:page_step] += 1
session[('page' + session[:page_step].to_s).to_sym] = current_path if session[:page_step] > 1
end
#return link for previous page in page step
def step_back
session[:page_step] -= 1
end
的問題是,2個PARAMS在url_handler不檢索@return_to和0在index.html.erb中傳遞。傳遞時@return_to有一個有效值。
該問題的任何解決方案?謝謝。
工作!謝謝。 – user938363