📄 03 - redirecting to a different location.rb
字号:
class BureaucracyController < ApplicationController def index redirect_to :controller => 'bureaucracy', :action => 'reservation_window' end def reservation_window redirect_to :action => 'claim_your_form', :id => 123 end def claim_your_form redirect_to :action => 'fill_out_your_form', :id => params[:id] end def fill_out_your_form redirect_to :action => 'form_processing' end def form_processing redirect_to "http://www.dmv.org/" endend#---"GET /bureaucracy HTTP/1.1" 302"GET /bureaucracy/reservation_window HTTP/1.1" 302"GET /bureaucracy/claim_your_form/123 HTTP/1.1" 302"GET /bureaucracy/fill_out_your_form/123 HTTP/1.1" 302"GET /bureaucracy/form_processing HTTP/1.1" 302#---class DangerController < ApplicationController def index redirect_to :action => 'safety' unless params[:i_like_danger] do_something_dangerous end # ...end#---class DangerController < ApplicationController def index (redirect_to :action => 'safety' and return) unless params[:i_like_danger] do_something_dangerous endend#---
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -